|
|
|
Many thanks for the link. It has been most useful... So useful in fact that I've added it to my signature so everyone will know about it!
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
The Second EuroCPian Event will be in Brussels on the 4th of September
Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!
|
|
|
|
|
Got a "crash" in the designer. I have a custom form that has almost no code in it and works fine, both in code and in the designer. I create a new inherited form from that custom form. The inherited form *immediately* (i.e. I make no changes from the code that is generated) shows the following error when I try to open it in the designer: "Object reference not set to an instance of an object".
Note that the inherited form and the base form are NOT in the same assembly, but the inherited form's assembly DOES reference the base form's assembly.
Also note that the code compiled just fine, and runs fine when I create an instance of the inherited form.
Any takers?
~Steve
|
|
|
|
|
Where the classes are (i.e., in what assembly) doesn't matter so long as the assemblies are resolvable by the project that use types in those assemblies. This could be your problem.
Design-time components should typically be installed into the GAC for this very reason. See How the Runtime Locates Assemblies[^] in the .NET Framework SDK for more information.
You should also consider debugging VS.NET. Yes, that's right. Open another instance of VS.NET and either attach to the former devenv.exe process or start a new one. Open your projects (works best with debug builds, of course) and try designing your components. It's fairly common to do so when extending the design-time capabilities of your components.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Heath, thanks for the reply. I'll give it a go. Is there anything I should know about installing things into the GAC? If my base form and inherited form are both changing frequently, should I just put a post-build event to install dll's into the GAC after each build? I'm guessing that after a while I'll end up with a ton of useless versions of my dll in the GAC that way. Should I make "uninstall previous" and "install current" post-build events?
Again, thanks for your help...
~Steve
|
|
|
|
|
For one, don't use automatic versioning (i.e., using an asterisk (*) in your AssemblyVersionAttribute ). Fix your version numbers using a versioning schema to your liking. Version numbers on .NET assemblies actually mean something unlike version numbers for Win32 executables. If a two Types differ only by version numbers, they are not the same Type.
If you're going to install into the GAC, you have to sign your assembly (which you should do anyway - there's never an excuse not to). Use sn.exe -k KeyFile.snk to generate a key pair named KeyFile.snk (or whatever you want to call it) and set the path in your AssemblyKeyFileAttribute , or install it into a CSP using sn.exe -k KeyPair.snk MyKeyPair and use that name ("MyKeyPair") in your AssemblyKeyNameAttribute . I recommend using the same key pair for all your assemblies, or at least all your assemblies for a particular product.
You don't need to uninstall these as the GAC allows for side-by-side versioning of assemblies. If these assemblies are changing often, however, I recommend that that you don't install into the GAC and make sure you set up a Project reference - not a simple assembly reference - in your multi-project solution so that Project B has a dependency on Project A - not Project A's assembly. This keeps versions and builds of assemblies in sync and you should not have the problems you're having (unless something else is causing it, of course).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Excellent! Thanks a bunch for all the info. I will definitely plan on doing all of this (probably won't use the GAC, but WILL strongly name my assemblies).
I have indeed solved the problem with the designer (problem in original post), but see that I have some work to do in configuring my projects/assemblies.
One last question... you mention setting my version with the AssemblyVersionAttribute . That is fine, but this project will have 20+ assemblies once it is complete. I don't want to have to go into each assembly and update the build number for every "internal" build (about once every 3 days) and for each release of the project. Is there a good way to make that happen dynamically? (ok, now that I think about it, I should probably search the site for an article...)
Anyway, thanks again! You've been a real help.
~Steve
|
|
|
|
|
You won't really find any articles on this.
I manage a project with over 60 assemblies (it's a massive N-tier application with several alternative tiers and utilities). Automatic versioning was a nightmare. I quickly threw that out and went with a simple approach.
The major and minor version numbers don't change very often at all. The build number (the third number) is the number of days since Jan. 1, 2000 (wrote a simple program to calculate that) for the milestone. The revision is incremented for any changes done between milestones that must be published into the test directories.
See, the assembly version is really most important when you deploy your assemblies. Since one alternative tier of our application uses touchless dpeloyment over the Internet, Fusion (part of the assembling binding in the .NET Framework) downloads and caches assemblies based on their version number into the Temporary Assembly Cache (also allows for side-by-side versioning). If you fixed a bug and re-released an assembly with the same version, it may not be downloaded to clients who got the first one. That's when changing the versions is most important. You really don't need to change it in between builds when just testing on your machine.
This also causes massive nightmares when you use late-binding, i.e. instantiating Types using .NET reflection (like Activator.CreateInstance ; building plug-in style applications or using the provider pattern). You can use publisher policies (specially named assemblies, roughly) and/or the assemblyBinding section of the .config file to redirect assembly versions.
you should read Redirecting Assembly Versions[^] in the .NET Framework SDK for more information if you're interested.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hmmm, well you've definitely caught my attention. I've been developing C++ for some time now, but this is my first go at .NET. I'm quickly learning that I have a ton to learn.
Thanks for the lesson (and the link). I'll start doing my homework now
~Steve
|
|
|
|
|
I am currently developing an asp.net application that develops crystal reports using the push method. What I am wondering is if I can allow the user to specify sort options during runtime while they are viewing the report information in the .asxp page? For instance I have a report that displays three bits of information about a part(PartNumber,RevisionNumber,CallNumber). I am wondering if I can allow the user to switch between sorting the records by these given fields and just have the page reload with the same data in the newly selected sorted order. Thanks in advance for any help
Frank Lepkowski
PS Sorry if this is not posted where it should be I was not sure were to stick the post!
Live today like it's the last day of your life..........
|
|
|
|
|
Yes you can specify which fields to sort, and there is, IIRC, even an example in the CR for .NET (not C# .NET - any .NET language unless the CR assemblies aren't CLS-compliant, but that only rules out crappy languages like JScript.NET).
There are several ways you could do this. You could specify a grouping in your report that accepts parameters. There are several ways to pass those, which are documented in the CR documentation. For example, you could set parameters using the ReportDocument.DataDefinition property.
You could also design the report to use an ADO.NET DataSet , which would give you maximum flexibility since you could sort and filter the DataSet and then set that as the report data source using ReportDefinition.SetDataSource .
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
My reports have been reporting off of ADO.NET datasets the whole time, this will be perfect I can just sort the dataset before i set the report source!
Thanks Heath
|
|
|
|
|
How would I go about creating a Properties file for the Tab Control ?
|
|
|
|
|
A "Properties file"? Please explain a little more.
If you're talking about displaying the properties for a file, then use P/Invoke the shell helper API, SHObjectProperties :
[DllImport("shell32.dll", CharSet=CharSet.Unicode)]
private static extern bool SHObjectProperties(
IntPtr hWnd,
uint dwType,
string szObject,
string szPage);
public void ShowProperties(string filename)
{
if (filename == null) throw new ArgumentNullException("filename");
if (File.Exists(filename))
SHObjectProperties(this.Handle, 2, filename, null);
} This would only work on Windows 2000 and newer, since SHObjectProperties is only supported in newer versions of shell32.dll. There are other ways to accomplish what this helper API does, but you need to understand the shell APIs and PIDLs.
If you want to add a property page to a file's property sheet, you need to implement the unmanaged interface IShellPropSheetExt , among other interfaces, which means you have to declare managed interfaces, implement them, and register your .NET assembly as a COM server. There are several articles about how to do this here on CodeProject.
If neither of these is what you mean, then you should define what you mean by "Properties file" because that's very vague and not technical at all.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
My apologizes for not explaining further. I want to create a properties file, that when invoked creates a Tab Control and sets its properties. I want to do this programatically not via the properties tool bar, in the Visual Studio.net environment. Thanks for your response
|
|
|
|
|
That still makes absolutely no sense. You can't invoke a file for one thing. You can read it, write it, delete it, copy it, and otherwise modify it, but you can't "invoke" a file.
And what "properties tool bar" are you talking about? You mean the PropertyGrid?
If you're talking about creating controls programmatically from information in a text or binary file, there are several ways of doing this. One is from Marc Clifton who's basically modeled his framework after XAML - the XML dialect for Windows "Longhorn" to create applications (not the only way, mind you). See MyXAML--XAML-style gui generator (added styles)[^].
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I guess i cannot Technically explain it. I was looking for something along these lines :
BackgroundSkin=???.bmp
NumberofTabs=2
Tab1Name=Mike
Tab1Pict = ???.bmp
Tab2Name=Jen
Tab2Pict=???.bmp
etc
|
|
|
|
|
Yeah, and the article I linked is one way to do that.
Basically, if you want to read properties from a file you need to parse the name/value pairs and use reflection to assign properties. This typically means you need a file structure that also dictates what those properties (like the ones you have above) apply to. To have a file for every control is absurd. With Marc Clifton's port of XAML (MyXaml), he does just that through XML hierarchies. You should take a look at it.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Can't find a search button for these forums, only the articles. I'm sure there is a wealth of info in the forum database ...
~Steve
|
|
|
|
|
Its to the top right of where the comments start. Click here[^].
#include "witty_sig.h"
|
|
|
|
|
Near the top of each forum is a "Search Comments" link.
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
The Second EuroCPian Event will be in Brussels on the 4th of September
|
|
|
|
|
Beat ya to it! :dances around room waving arms in the air:
#include "witty_sig.h"
|
|
|
|
|
|
Just below the code project logo
or
you can use this link
http://thecodeproject.com/script/comments/search_comments.asp?forumid=1649
Sreejith S S Nair
|
|
|
|