|
SLOSifl posted:Attribute stuff Fiend posted:Having an issue with this code on one of two XP machines, both with the same config: Either the Request object is null, or the Url object on the Request object is null.
|
# ? Jan 11, 2007 23:18 |
|
|
# ? Jun 10, 2024 13:15 |
|
Lone_Strider posted:Either the Request object is null, or the Url object on the Request object is null. I understand that it's the Uri object from the error, it's the "why" I need advice on.
|
# ? Jan 11, 2007 23:22 |
|
Fiend posted:I understand that it's the Uri object from the error, it's the "why" I need advice on.
|
# ? Jan 11, 2007 23:23 |
|
lightbulbsun posted:Comments on NetTiers, anyone? It'd better be perfect or else you'll spend more time fixing it than you will save. I can't tell how well NetTiers works from their website, but maybe I'll try passing it the ARTS data model and see what it does. (a 600+ table standardized data model used in retail systems. Here's a simplified list of the data structures NetTiers would be expected to generate in some form - http://www.nrf-arts.org/xml_dictionary_5/XMLDictionary-NonMembers.html)
|
# ? Jan 11, 2007 23:26 |
|
Lone_Strider posted:If it's possible, can you post the code for all of that? I've been playing around with custom attributes for generating help files and I'd love to see examples of how other people use them. I'll throw together a detailed post and possibly an actual sample project if I get a chance this afternoon. Here's what the program looks like (I'm working on some layout stuff now): Everything in the main area (i.e. not the buttons or entry box) is built from in-code objects that either self describe, are described in the database, or a combination. That area is called the Journal, but all it really is is a container for Object Views. An Object View is the control that knows what to do with all those visual attributes. It loads them once per type and stores them in various collections (there are 3 layout modes possible) and looks up all the property values dynamically when needed. All drawing is cached to a backing bitmap and displayed when needed, to avoid having to look poo poo up constantly. Loading all the information for about 12 different types (that means looping through all their properties), including hitting the database once per type, takes about half of a second. SLOSifl fucked around with this message at 00:14 on Jan 12, 2007 |
# ? Jan 11, 2007 23:34 |
|
Fiend posted:Having an issue with this code on one of two XP machines, both with the same config: Are the XP machines you're talking about both hitting the same website? Where is the site hosted? Anything different network-wise between the two clients?
|
# ? Jan 12, 2007 00:14 |
|
Heffer posted:Here's example #1 of how things could go wrong. Say you have a table that contains a field for an ID number (2 bytes) a date (8 bytes) and the file itself (32,000 bytes). The rows for the table ordinarily get stored consecutively on the disk, and the database only keeps track of where the first row is, apart from indexes and such. Wouldn't this be solved by having an an index on the date field? Then it just has to read through the index which is something like 10 bytes per entry. If you're already inserting large files into the database, you're probably not worried about the overhead of an index. I can see where example 2 makes sense though.
|
# ? Jan 12, 2007 00:16 |
|
pig-fukr posted:Are the XP machines you're talking about both hitting the same website? Where is the site hosted? Anything different network-wise between the two clients? Both machines are hosting the same code for the web site and have the same iis configuration. One machines returns that error.
|
# ? Jan 12, 2007 00:27 |
|
In C# ASP .NET 2.0, is there a way to get a mime type from a file extension. I've seen one way by searching through the registry, but I was hoping there was a less hackish way.... Any ideas?
|
# ? Jan 12, 2007 00:36 |
|
Fiend posted:Both machines are hosting the same code for the web site and have the same iis configuration. One machines returns that error. What happens if you force the issue and remove the Request object, substituting a hard coded ip? Also, what happens if you try to write out a straight "Request.ToString()"? Seems bizarre that the Request object itself would be null, there has to be something else...
|
# ? Jan 12, 2007 00:41 |
|
SLOSifl posted:
|
# ? Jan 12, 2007 00:44 |
|
Lone_Strider posted:That UI looks awesome. I'll PM you, thanks This sample contains the following: 1) A project that has a form, and defines a few attribute classes. 2) A project that defines a few classes and defines some methods and properties with attributes attached. The second project generates an assembly in its bin\Debug (or Release) folder as usual. The other program has a "Load Assembly" button. You can load any .NET assembly into the program and it will generate a simple tree with classes, methods and properties. Any property or method with a ProperyAttribute or MethodAttribute defined will get a child node on the tree with the text supplied. I got lazy and didn't hook up the ClassAttribute to display anything, and I didn't make an attribute that can be attached to any type of object (the equivalent of your "Note" attribute from your PM). I figure those are no big deal. (I just realized that I copied and pasted a typo over and over. Ignore the "alwasy" that was supposed to be "always" ) Open the solution, run it, and then navigate to the TestAssembly's bin\Debug folder and select the dll. Oh, and I didn't comment any of the code. http://pandaflash.googlepages.com/AttributeDemo.zip --------------------------------------------------------------------- Okay, now I'll explain it once you have it loaded up. It's not that complicated in reality, so I'll try to be brief. I will focus only on the MethodAttribute class defined in Attribute.cs, since they're all the same thing anyway. code:
The AttributeUsage is there to say "only allow this to be attached to Methods, don't allow multiple ones per method, and let this attribute come with the method if inherited". Pretty self explanatory. Poke around it with VS's Intellisense a bit. Other than that attribute and the non-essential naming convention, it's really just a class. You may want to provide multiple constructors if you have a lot of properties, *but* you can take advantage of a neat bonus attributes get: Named parameters. Intellisense will even list them for you when it comes time. code:
So that's an attribute. There are some little caveats, like not being able to use certain datatypes as properties when using a constructor or named params (this is a limitation of the way you declare the attribute inline), but I found them to be easily worked around. For example, I specify my colors for the UI using a syntax like this: "#A,R,G,B" instead of passing in a Color. In Classes.cs, we'll go ahead and apply a few attributes. Again, they're all basically the same so I'll focus on just a single Method. code:
The only thing to see here is the syntax, which you are already aware of. Here is a slightly more complicated one from my real application: code:
In the ProcessType method in Form1.cs, here is the part that deals with the MethodAttributes: code:
First I grab an array of all the Methods defined by the class. For each method, I create a new node on the tree and set its display text. Then I grab all the custom attributes of type MethodAttribute (note that I need to use the full name here). If there are any, I add a child node to the method's node and set that text to attribute.Description. As I mentioned before, it's just a normal class. That's about it. It's easy to build them and apply them, and it's really just what you do with that metadata that's important. SLOSifl fucked around with this message at 07:54 on Jan 12, 2007 |
# ? Jan 12, 2007 01:22 |
|
I'm just posting to say that attributes, as described above, are one of my favorite features of .NET. You can do a lot of really cool meta-programming with them and save yourself a boatload of work in so many situations. And also, once you discover the compiler-magic ConditionalAttribute, you'll never use "#if DEBUG" ever again.
|
# ? Jan 12, 2007 02:08 |
|
Fiend posted:Having an issue with this code on one of two XP machines, both with the same config: Are you sure that both machines have the same version of ASP.NET configured with IIS? This code works for me: code:
code:
code:
|
# ? Jan 12, 2007 04:12 |
|
Heffer, do you know that SQL Server doesn't store fields any larger than 8000 bytes in-row? Instead, it uses 16-byte pointers. The scheme you described could never happen with SQL Server, unless all the files are less than 8000 bytes and the store-text/image-in-row option is turned on. I don't know what other RDBMSes do.
|
# ? Jan 12, 2007 05:47 |
|
poopiehead posted:In C# ASP .NET 2.0, is there a way to get a mime type from a file extension. I've seen one way by searching through the registry, but I was hoping there was a less hackish way....
|
# ? Jan 12, 2007 06:15 |
|
biznatchio posted:And also, once you discover the compiler-magic ConditionalAttribute, you'll never use "#if DEBUG" ever again. SLOSifl fucked around with this message at 08:07 on Jan 12, 2007 |
# ? Jan 12, 2007 08:01 |
|
SLOSifl posted:That's about it. It's easy to build them and apply them, and it's really just what you do with that metadata that's important. Any ideas on using attributes to define an array of objects? I'm not sure if it's possible if the objects are reference types (require instantiation) but I haven't found anything definitive. I'm trying to use attributes to define a list of options that a plugin assembly can support, but it's not working exactly as I had it planned in my head
|
# ? Jan 12, 2007 17:11 |
|
csammis posted:Any ideas on using attributes to define an array of objects? I'm not sure if it's possible if the objects are reference types (require instantiation) but I haven't found anything definitive. I'm trying to use attributes to define a list of options that a plugin assembly can support, but it's not working exactly as I had it planned in my head More realisitically, you could define an attribute with a lot of bools, one for each option. Then use named parameters to set them to true when supported. code:
Or maybe I'm missing what you mean by deinfing an array of objects? Internally, attributes can contain arrays and anything else you want. Defining an array in the constructor *might* be off limits - I can check. I wouldn't be surprised if an array of an alreay allowed type is okay though. edit: this: code:
"An attribute argument must be a constant expression, typeof expression or array creation expression" That's the limitation - they must be constant, like a string (or int, bool, etc), a typeof (which should be a constant anyway, right?) or an array of one of the supported types. It looks like your best option is to create the array internally from allowed values, if possible. It's also possible that, in your case, the list of supported options is actually best as a property of the class, although I do see the attribute angle making a lot of sense. SLOSifl fucked around with this message at 17:48 on Jan 12, 2007 |
# ? Jan 12, 2007 17:41 |
|
SLOSifl posted:
Yeah, I was playing with this last night, and that was what I was running into...the documentation was not great on what exactly the error meant, so I wasn't sure if I was missing something. Looks like I was right quote:It looks like your best option is to create the array internally from allowed values, if possible. It's also possible that, in your case, the list of supported options is actually best as a property of the class, although I do see the attribute angle making a lot of sense. That's what we're doing right now, the configuration options are exposed as a List<ShaimPluginOption> in a property defined by the plugin interface. The problem we're running into is that the plugin loader has to scan the assembly, find the plugin object, instantiate it (this is the bitch part of it, I'm trying to avoid instantiating the relatively large plugins that may not even be used just for configuration), then get the property. I've been refactoring simple plugin properties like names, authors, descriptions, whether or not to show it in the configuration list, etc. as assembly-level properties. Being able to specify typeof gives me an idea though... code:
|
# ? Jan 12, 2007 17:56 |
|
csammis posted:
I guess a static method could work too, but that looks like a much more elegant option.
|
# ? Jan 12, 2007 19:09 |
|
SLOSifl posted:Very nice! I like the attribute approach because if a plugin doesn't have any configurable options, it just doesn't use the attribute
|
# ? Jan 12, 2007 19:23 |
|
mr brown posted:Are you sure that both machines have the same version of ASP.NET configured with IIS? Even the expression to eval if the .Url property is null throws the error. code:
|
# ? Jan 12, 2007 21:22 |
|
Fiend, you aren't causing the NullReferenceException: ASP.NET is, inside the GetServerVariable method as indicated by that call stack. Apparently it's an ASP.NET bug. You might want to peek at all the server variables in the Request object to see if the relevant information is there for ASP.NET to build you a Url object. You could also use a tool (like Lutz Roeder's Reflector) to see exactly what is causing the exception, although that might be a bit tricky.
|
# ? Jan 12, 2007 21:40 |
|
XAML question ( probably for csammis ) Has anyone had any luck with using the XAML design view in the real application? It works fine for me on simple projects but appears to get hosed when I start added xmlns definitions in some of the files. The app compiles and runs without any problems, I'd just like to use the visual XAML editor. Both Window1.xaml and color_control.xaml fail in the Design view. I'm pretty sure I'm up to date on the all the .NET 3.0 SDKs and VisualStudio extensions. Window1.xaml fails with Error 3 Value 'Resources\window_close_button.xaml' cannot be assigned to property 'Source'. C:\code\software\IntevacDesigner\App.xaml 10 Error 4 Value 'Window1.xaml' cannot be assigned to property 'StartupUri'. C:\code\software\IntevacDesigner\App.xaml 4 and color_control.xaml fails with Error 1 Value 'Window1.xaml' cannot be assigned to property 'StartupUri'. C:\code\software\IntevacDesigner\App.xaml 4 Here's what my xaml files look like App.xaml code:
code:
code:
|
# ? Jan 12, 2007 23:04 |
|
fankey posted:XAML question I don't see anything immediately wrong, but it looks like the specific errors you're seeing are most likely the fault of the designer. I don't use a visual designer for XAML, not the one in Visual Studio nor Expression/Sparkle/Blend/Whatever it's called now. Neither of them are anything to write home about, if you ask me, and I stopped using them specifically because they broke down when I started importing namespaces. It may be better for you to ask on the Avalon forums.
|
# ? Jan 13, 2007 00:39 |
|
Fiend posted:I'm pretty sure! Victor posted:Fiend, you aren't causing the NullReferenceException: ASP.NET is, inside the GetServerVariable method as indicated by that call stack. Apparently it's an ASP.NET bug. You might want to peek at all the server variables in the Request object to see if the relevant information is there for ASP.NET to build you a Url object. You could also use a tool (like Lutz Roeder's Reflector) to see exactly what is causing the exception, although that might be a bit tricky. Victor makes an excellent point here, I neglected to read the stacktrace. Googling some for "GetServerVariable NullReferenceException" yields these two threads in which someone runs "aspnet_regiis -i" which fixes the problem for them. I'm really, really surprised your code was able to get that far without ASPNET being properly registered with IIS, but I suppose stranger things have happened. Reflector shows that ISAPIWorkerRequestInProc.GetServerVariable does a lot with looking up what appear to be internal IIS/ASPNET environment variables.
|
# ? Jan 13, 2007 03:19 |
|
SLOSifl posted:Here's the one rule about code generation programs: The question is, if the code generation scripts even do a mediocre job of creating a business, data layer, and even O/R mapping system for you, doesn't it seem likely they'd save you time any way you'd slice it (unless they *really* screwed things up).
|
# ? Jan 13, 2007 06:38 |
|
DLCinferno posted:....Is there a way to get the mime type from the file extension without using the registry? .... Yes, figure out what each file formats' header is. Most binary files have special header at the top of the file. It will be different for different file types. It will be stored at a different location for each file type. It will likely be stored in the first 12 bytes of the file. The registry is easier, but can sometimes "lie" since you are just checkng for file associations instead of actually using the semantics of the file itself to check its type. For a good example look up most unix file types, or look at the bitmap or jpeg file formats. Have fun.
|
# ? Jan 13, 2007 07:08 |
|
wwb posted:I have yet to manage to melt down a SQL server because it was serving files out of the database, but that is me. I work at a newspaper, and we use some monstrous databases for layout files, photograph storage, and other assorted information and files. Right now we're at umm... 2 Terabytes? Maybe 4 TB. One of the big problems is that AP Photographers and the such are getting higher resolution digital cameras. You qaudruple the resolution of most incoming photos, and things start to get out of hand. We've adopted some pretty serious policies on pushing outdated content and materials to an archive or external store, but we can't stop everything. Theres a simple trend analysis we do to look at what the average increase in size of the database is versus what the max disk size we can squeeze into the server. We got about 10 months before we hit a brick wall, and the database curls up and dies.
|
# ? Jan 13, 2007 07:27 |
|
Grid Commander posted:Yes, figure out what each file formats' header is. Most binary files have special header at the top of the file. It will be different for different file types. It will be stored at a different location for each file type. It will likely be stored in the first 12 bytes of the file. Thanks for the info. What I, and I'm assuming Grid Commander, are looking for is to return the same Content-Type header as the web server would for a given file. Servers just look up extensions in a table they have and return the associated content type. I probably didn't make that clear in the original question. In my case, what I'm trying to do is dynamically serve up files through a server side script. I'll know the extension that the file originally had, so I'd like to get the content type from that. I can store the content type when the files are uploaded, but would rather avoid it. poopiehead fucked around with this message at 07:55 on Jan 13, 2007 |
# ? Jan 13, 2007 07:51 |
|
Grid Commander posted:[Is there a way to find the mime type without using the registry?] There's already a windows function which does this -- looks at the data to determine its type: FindMimeFromData
|
# ? Jan 13, 2007 08:00 |
|
Heffer posted:I work at a newspaper, and we use some monstrous databases for layout files, photograph storage, and other assorted information and files. Right now we're at umm... 2 Terabytes? Maybe 4 TB. One of the big problems is that AP Photographers and the such are getting higher resolution digital cameras. You qaudruple the resolution of most incoming photos, and things start to get out of hand. Valid point, but that is fundamentally a disk space issue, not a "all these images are making SQL server die" issue. On NetTiers: first, SLOSifl's comment is very, very poingnant. Always keep that in mind. Anyhow, NetTiers is pretty slick, and does do a reasonable job of creating a table adapter style ORM layer with some nice extensibility points. But it is still a generated, table-adapter style ORM that encourages data-, not behavior-centric programming.
|
# ? Jan 13, 2007 18:36 |
|
ljw1004 posted:There's already a windows function which does this -- looks at the data to determine its type: Nice!! And elegantly named, guess it shows what an extra 10 seconds of research might have turned up if i had just typed that stuff into Google. Thanks for pointing that out.
|
# ? Jan 14, 2007 02:37 |
|
ljw1004 posted:There's already a windows function which does this -- looks at the data to determine its type: Here's the PInvoke link for anyone else: http://www.pinvoke.net/default.aspx/urlmon/FindMimeFromData.html
|
# ? Jan 14, 2007 03:09 |
|
DLCinferno posted:Very cool. Thanks! Is it just me, or is the declaration on that site horribly mangled? edit: Your ninja-edit makes me look
|
# ? Jan 14, 2007 03:13 |
|
Any of you WPF wizards knows whether or how I can force the DWM in Vista to enable shadow on windows without frame? As soon I set WindowStyle to None and set AllowsTransparency, it poofs. I managed to get blur back via PInvoking some DWM functions, but there doesn't seem to be a way to force the shadow. Meanwhile, I'm doing the shadow in the client area using a nine grid, but I'd like the system to the shadow. Evidence (9grid vs DWM):
|
# ? Jan 14, 2007 19:47 |
|
Toiletbrush posted:Any of you WPF wizards knows whether or how I can force the DWM in Vista to enable shadow on windows without frame? As soon I set WindowStyle to None and set AllowsTransparency, it poofs. I managed to get blur back via PInvoking some DWM functions, but there doesn't seem to be a way to force the shadow. Try setting ClipToBounds = false. I'm not sure if that works with the root window but it did fix a similar problem I was having getting drop shadows to show up on some controls placed inside a Canvas.
|
# ? Jan 15, 2007 07:20 |
|
I'm thinking of starting to programme in C# instead of VB. I have a large VB project and was wondering if it's possible to begin writing new classes (or even forms) in C# within this project? I heard that all code compiles the same so I was wondering if it's possible.
|
# ? Jan 15, 2007 09:03 |
|
|
# ? Jun 10, 2024 13:15 |
|
fankey posted:Try setting ClipToBounds = false. I'm not sure if that works with the root window but it did fix a similar problem I was having getting drop shadows to show up on some controls placed inside a Canvas. Combat Pretzel fucked around with this message at 15:30 on Jan 15, 2007 |
# ? Jan 15, 2007 15:28 |