Yes, it works great, thanks a lot! Regards, Andre Loker
VizOne
Posts
-
XPath: Select all nodes that DON'T contain certain subnodes -
XPath: Select all nodes that DON'T contain certain subnodesHi! I need to select certain nodes that DON't have specific subnodes, i.e. Select all nodex x/y where there is no subnode x/y/a or x/y/b Example: blup test bla bla I'd appretiate all suggestions. Thanks in advance! Regards, Andre Loker
-
AppDomain.DomainUnload never fired automaticallyProcessExited only works for the main AppDomain (and even then, I find strange bevahvior to occur). Regards, Andre
-
AppDomain.DomainUnload never fired automaticallyHi! In my app I'd like to execute some code when an AppDomain is unloaded. I expected AppDomain.DomainUnload to be suitable for this, however the event never gets raised automatically - only if I call AppDomain.Unload with that AppDomain. Example:
class Class1
{
static void Main(string[] args)
{
// subscribe to current domain
AppDomain.CurrentDomain.DomainUnload += new EventHandler(CurrentDomain_DomainUnload);// and for testing to another domain: AppDomain domain = AppDomain.CreateDomain("Test"); domain.DomainUnload += new EventHandler(CurrentDomain\_DomainUnload); // if I uncomment this, the event is fired for 'domain': //AppDomain.Unload(domain); } public static void CurrentDomain\_DomainUnload(object sender, EventArgs e) { Console.WriteLine("Unloading appdomain"); AppDomain domain = sender as AppDomain; if(domain != null) Console.WriteLine("... unloading domain is: " + domain.FriendlyName); }
}
I find this quite irritating. How can I implement some kind of per-AppDomain shutdown function? Thanks in advance. Regards, Andre Loker
-
delegate and AppDomainsHi! I have an application with two AppDomains (say A and B) where an object X that lives in AppDomain A is passed to AppDomain B where a method subscribes for an event of object X. This means that when object X fires its event, the delegate is called over AppDomain boundaries. This works well as long as the method the event-delegate points to (in AppDomain B) is public. If the method is anything but public (e.g. internal, private or protected) I get an SerializationException saying that it the serialization does not serialize delegates pointing to non-public members. I find this strange and annoying as I don't want to make the method in question public. Any suggestions? Thanks in advance Regards, Andre Loker
-
VC++ 6.0 with C# dllWhat you can do is creating a typelib (.tlb) of the C# .dll with tlbexport.exe and access the C#-classes like COM-Objects from within C++. Regards, Andre
-
MC++ indexed properties and C#Paul Selormey wrote: Andre claims it is a bug Well, I did not say it is a bug. All I said was that a) As DefaultMember makes the property in question the indexer for C# (e.g. public string this[int index]{get; set;} ), there can be only one indexed property in C# b) The way the indexer is accessed (instance[5] instead of what on expect for a indexed property instance.MyProp[5]) makes the class look array-like. So, after all, it is not a missing feature in MC++ (which supports indexed properties), but more of a missing feature in the C# specifications. (BTW. it is System.Reflection.DefaultMemberAttribute) Best regards, Andre P.S.: damn, i hate it when I have to rewrite the whole post just because I forgot to log in :)
-
Bug in VC++.net 2002: nested structsHi! I have a class that contains several nested structs:
public __abstract __gc class Foo { public: __value struct Struct1 { /** }; __value struct Struct2 { /** }; __value struct Struct3 { /** }; __value struct Struct4 { /** }; [...] };
However, that maximum number of nested structs seems to be 17. Whenever I add the 18ths struct, I get an internal compiler error. Is this a confirmed bug? Regards, Andre -
Intellisense and multi file assemblyHuh? Which version are you using? I have two c# module that I compile from the command line using /target:module, lets say part1.module and part2.module. Then I use al.exe to create a manifest for these two modules (foo.dll). If I add foo.dll to the references list (only the file foo.dll, no projects), I don't see any of the types of the modules. However, I can use the types and compile the program. I got a post in microsoft.public.dotnet.languages.csharp that this is a known limitation (or bug if you want so). It would have been *sooo* nice :( - Andre
-
Covariant return types -
Covariant return typesHi Paul Just to give you an example:
public __gc class MyData { /**/ }; public __gc class MyCollection : public CollectionBase { public: __property MyData * get_Item(int in_index) { return static_cast<MyData*>(List->Item[in_index]); } __property void set_Item(int in_index, MyData * in_data) { List->Item[in_index] = in_data; } };
The (German) output is:Covariant4.cpp(19) : error C3815: Der Rückgabetyp der Methode 'MyCollection::get_Item' muss mit dem Typ des letzten Parameters von 'System::Collections::IList::set_Item' übereinstimmen Covariant4.cpp(18) : Siehe Deklaration von 'MyCollection::get_Item' Covariant4.cpp(6) : Siehe Deklaration von 'System::Collections::IList::set_Item' Covariant4.cpp(19) : error C2392: 'MyData __gc *MyCollection::get_Item(int)' : Covariant-Rückgabetypen werden in verwalteten Typen nicht unterstützt
Translated: C3815: Return value of 'MyCollection::get_Item' must match the type of the last parameter of 'System::Collections::IList::set_Item' C2392: 'MyData __gc *MyCollection::get_Item(int)': Covariant return types are not supported in managed types It seems to me as if this has been fixed in vs2003. Damn, I'm looking forward to it :) - Andre -
Intellisense and multi file assemblyHi! I have a multi file assembly that exists of two modules and a .dll that contains the manifest. If I add a reference to the manifest dll into my c# project, I can access the types within the modules, however they are not shown in the intellisense window. Is there any way to make them appear in the intellisense window? Thanks in advance! - Andre
-
Linking several .net modules into one .dllNice tool, leppie. However I need to link a mc++ module with native code as well :( which is something that cannot be done using ildasm/ilasm. - Andre
-
Linking several .net modules into one .dllThank you for the link, but this exactly what I wanted to *avoid*: having the assembly split over several modules. Instead I wanted several modules to be physically embedded into one final .dll. Let me explain my motivation: I have a dll written in c++ with managed extensions. I use MC++ as I do a fair amount of IJW and COM-Interop. However, I need a collection derived from CollectionBase that reimplements object* get_Item(int) with a covariant return type (SomeType * get_Item(int)). As this does not seem possible in MC++ but well in C# (I posted my problem before: http://www.codeproject.com/script/comments/forums.asp?forumid=3785#xx455157xx), I decided to write the collections in C#. So I would have a "main" dll e.g. GentleStorm.Nasty.Graphics.dll and a module with the collections GentleStorm.Nasty.Graphics.netmodule It would be nice if I could embed the latter into the first, so that I only have to distribute the .dll - Andre
-
Linking several .net modules into one .dllHi! (I hope this is the correct forum for this question) I have a bunch of .net modules, written in different languages (managed c++ and c#). Now I'd like to link them all together into one .dll. I tried using al.exe, but this tool only generates an assembly manifest, that refers to the external modules rather than embeds them into the dll. Then I tried this: I disassembled all modules with ildasm and then tried to re-assembly the .il files with ilasm into one final .dll. Hower this does not work, as my modules contain native functions. What can I do? Thanks in advance - Andre
-
Covariant return typesHi! I'd like to implement my own Collection that derives from Collection Base. I want the Item-property to have the proper return type instead of Object*. In C# it is easy to implement a Covariant return type:
class MyData { public int Value { get { return 5; } } }; class MyCollection : CollectionBase { public MyData this[int index] // override indexer from IList { get{ return (MyData)List[index]; } set{ List[index] = value; } } };
In VC++.net, however it does not seem to be possible, as covariant return types are not allowed - at least in VC++.net:__gc class MyData { __property int get_Value() { return 5; } }; [Reflection::DefaultMember(S"Item")] // let Item be the indexer __gc class MyCollection : public System::Collections::CollectionBase { __property MyData * get_Item(int in_index) // C2392- Error! { return static_cast<MyData*>(List->Item[in_index]); } };
Is there any attribute or another way to achieve what I'd like to do? I am using VS.net 2002. Might this feature be available in vs.net 2003? Thanks in advance! - Andre -
resx-files in VC++.net 2002Hi Paul! I solved my problems and (as you said) use the command line tools. 1. I add the resource files (resx and txt for strings) and the localized versions to the project. 2. For the neutral resource, I set resgen $(InputFileName) $(InputName).resources as the commandline and "$(InputName).resources" as the output file 3. For all localized resources I set the command line to e.g. resgen $(InputFileName) $(InputName).resources al /v:1.0.* /target:lib /embed:$(InputName).resources /culture:de /out:$(OutDir)/de/$(TargetName).resources.dll and $(OutDir)/de/$(TargetName).resources.dll as the output file to create the satelite assemblies. 4. In the project settings Linker->Input->Embed managed resource file I add strings.resource That's it, works sweetly for me, although it is not as easy as it could be. Why does MS stick to .rc/.res in VC++.net 2002? - Andre
-
resx-files in VC++.net 2002Hi! I'd like to use localized resources in my managed C++ project. The System that is available in e.g. C# (resx - localized satelite dlls) is exactly what I am looking for, so it would be nice to use it. However, vc++.net 2002 does not seem to support this natively. I can only add the "good ol'" .rc files. How can I use resx files in my project? Do I have to write them manually, precompile them with resgen and then link them manually to my mc++ code? Will VC++.net 2003 support resx-files natively? Thanks in advance. Andre (VizOne) Loker
-
Creating objects on stackWhoops, it seems I did not get an e-mail notification. Something's going on in here, I see. I'm short on time right now, so I cannot post the test code (maybe it was a test way too naiv at all). I'll post it when I have a little more time. Thanks already for the interesting research, Jeff! - Andre
-
Creating objects on stackHi! I am working on a function that returns an object initilized with some specific values, like
__value struct MyStruct { public: MyStruct(int a, int b, int c) : a(in_a), b(in_b), c(in_c) {} static MyStruct One() { return MyStruct(1,1,1); } private: int a, b, c; };
This is compiled to the following MSIL-code:.method public static valuetype Cpp.MyStruct One() cil managed { // Code size 26 (0x1a) .maxstack 4 .locals (valuetype Cpp.MyStruct V_0) IL_0000: ldloca.s V_0 IL_0002: initobj Cpp.MyStruct IL_0008: ldloca.s V_0 IL_000a: ldc.i4.1 IL_000b: ldc.i4.1 IL_000c: ldc.i4.1 IL_000d: call instance void Cpp.MyStruct::.ctor(int32, int32, int32) IL_0012: ldloca.s V_0 IL_0014: ldobj Cpp.MyStruct IL_0019: ret } // end of method MyStruct::One
I looked at IL_0002 and found a initobj. I tried to avoid initializing of the members, so I defined an empty default c'tor: MyStruct() {} However, now my IL code expanded to:.method public static valuetype Cpp.MyStruct One() cil managed { // Code size 35 (0x23) .maxstack 4 .locals (valuetype Cpp.MyStruct V_0, valuetype Cpp.MyStruct V_1) IL_0000: ldloca.s V_1 IL_0002: initobj Cpp.MyStruct IL_0008: ldloca.s V_1 IL_000a: ldc.i4.1 IL_000b: ldc.i4.1 IL_000c: ldc.i4.1 IL_000d: call instance void Cpp.MyStruct::.ctor(int32, int32, int32) IL_0012: ldloca.s V_0 IL_0014: ldloca.s V_1 IL_0016: cpobj Cpp.MyStruct IL_001b: ldloca.s V_0 IL_001d: ldobj Cpp.MyStruct IL_0022: ret } // end of method MyStruct::One
Which contains a cpobj and two local instances of MyStruct and therefore seems to be even worse. I wrote a similar struct in C# to compare compilation output:public struct MyStruct { public MyStruct(int in_a, int in_b, int in_c) { a = in_a; b = in_b; c = in_c; } public static MyStruct One() { return new MyStruct(1, 1, 1); } int a, b, c; };
This compiled to the following code:.method public hidebysig static valuetype CSharp.MyStruct One() cil managed { // Code size 9 (0x9) .maxstack 8 IL