Assemblies References
-
Hi all, ¿Is it possible to compile 2 assemblies and making reference one to each other? Example: We want to compile MySoftware.exe and MyLibrary.dll, we do it as follow: csc.exe /target:winexe /out:MySoftware.exe /reference:MyLibrary.dll csc.exe /target:library /out:MyLibrary.dll /reference:MySoftware.exe I want both assemblies to access the other assembly methods but at compile time is obviously that the other file does not exist, so compile error displays. Thanx
-
Hi all, ¿Is it possible to compile 2 assemblies and making reference one to each other? Example: We want to compile MySoftware.exe and MyLibrary.dll, we do it as follow: csc.exe /target:winexe /out:MySoftware.exe /reference:MyLibrary.dll csc.exe /target:library /out:MyLibrary.dll /reference:MySoftware.exe I want both assemblies to access the other assembly methods but at compile time is obviously that the other file does not exist, so compile error displays. Thanx
A solution (but not the best) is to build a stupid MyLibrary.dll with the needed public class, but without implementation.
public class MyLibraryClass { public int ComputeSomething(int l, int r) { throw new NotImplementedException(); } }
Than build the exe against this stupid Library. Than build the real Library against the exe. I have not tested this solution. If you try it, please write your result. Good luck. Lars Niedziolka -
Hi all, ¿Is it possible to compile 2 assemblies and making reference one to each other? Example: We want to compile MySoftware.exe and MyLibrary.dll, we do it as follow: csc.exe /target:winexe /out:MySoftware.exe /reference:MyLibrary.dll csc.exe /target:library /out:MyLibrary.dll /reference:MySoftware.exe I want both assemblies to access the other assembly methods but at compile time is obviously that the other file does not exist, so compile error displays. Thanx
Heinz Suez wrote: csc.exe /target:library /out:MyLibrary.dll /reference:MySoftware.exe You should not reference an executable. MSDN says: "At run time, you should anticipate that only one .exe assembly can be loaded per process, even though, there may be times when more than one .exe might be loaded in the same process. Therefore, do not pass an assembly built with /target:exe or /target:winexe to /reference. This condition may be modified in future versions of the common language runtime." To solve your problem. Try either to move all functionality needed by MyLibrary into MyLibrary, so it can be compiled without referencing, or maybe create a second library that gets referenced by MyLibrary and MySoftware.