|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Using AL.exe to link modules into assemblyI'm writing a program that first uses csc.exe to compile C# files into a netmodule, which works fine. The resulting fileis 72 KB in size. Next it uses al.exe to link the netmodule to an assembly and add strong naming and resources. Below is a simplified example of the command I use: al /keyfile:myKey.snk /version:1.0.* /embed:myResource.resx /t:lib /out:myDLL.dll myModule.netmodule I was wanting the result to be a strong-named assembly with all the contents of the netmodule, plus resources. Instead, the assembly generated is 5 KB in size. When I use ildasm.exe to analyze the assembly and it's manifest, there are just external references to types that refer to the .netmodule, but no actual type information. I know about other tools such as sn.exe for strong naming and dynamic assemblies to emit the information, but I just don't know the best approach. Can anyone tell me how to take a module and add strong naming and resources to it? Or, how does Visual Studio do it? Thanks in advance, Shannon >Can anyone tell me how to take a module and add strong naming I don't understand why you're compiling to a module to begin with>and resources to it? instead of an assembly. The C# compiler can handle both strong naming (use the AssemblyKeyFile attribute) and embedding resources (the /res option). Mattias -- Mattias Sjögren [MVP] mattias @ mvps.org http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com Please reply only to the newsgroup. Hi Mattias,
Thank you for the quick response. In the last few minutes I discovered this myself. My original problem came from the fact that the AssemblyKeyFile attribute is stored in AssemblyInfo.cs. The way I would declare this is as follows: [assembly: AssemblyKeyFile(MyAssembly.snk")] When compiling in Visual Studio, it knew to get the .snk file from the obj\Debug directory. However, when I compiled it using ICodeCompiler, the compiler didn't know where to locate it. Therefore, I tried ignoring AssemblyInfo.cs when compiling, and adding the key later with the al.exe /keyfile option. Recently I found that if I change the AssemblyKeyFileAttribute to the following, it would locate the .snk file in both Visual Studio and ICodeCompiler. [assembly: AssemblyKeyFile(@"..\..\obj\Debug\MyAssembly.snk")] Now I can compile AssemblyInfo.cs with ICodeCompiler and use the /resource option to specify my resources. Everything seems to be working fine. I do have one question. Is embedding resources this way the same as using the EmbeddedResource compile option for the file in Visual Studio? Thank you for taking the time to respond. Shannon *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it! Shannon,
>I do have one question. Is embedding resources this way the same as Yes. Except perhaps that VS adds the namespace to the resource name,>using the EmbeddedResource compile option for the file in Visual Studio? I'm not sure if ICodeCompiler does that (I know the command line compiler doesn't). Mattias -- Mattias Sjögren [MVP] mattias @ mvps.org http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com Please reply only to the newsgroup.
Finalization and .NET/deterministic or orderly shutdown
How to negotiate authenication with HttpWebRequest Reversing text in TreeView nodes Reading Text datatype into a byte Array Strange behaviour with .NET apps with Framework 2.0 Deserialization constructor Exception with HttpWebRequest.GetResponse Dynamicly refrence a .NET DLL State of Objects... limits for filestreams (C#) |
|||||||||||||||||||||||