Merge .dll into C# Assembly?

后端 未结 3 1727
旧时难觅i
旧时难觅i 2021-01-06 03:58

Using #C.net 3.5

I\'m aware of the ILMerge and alike techniques, but I would actually like to make use of Jeffrey Richter\'s suggestions.

After adding this c

相关标签:
3条回答
  • 2021-01-06 04:33
    String resourceName = "AssemblyLoadingAndReflection." + new AssemblyName(args.Name).Name + ".dll";
    

    should be changed to:

    String resourceName = Application.Current.GetType().Namespace + "." + new AssemblyName(args.Name).Name + ".dll";
    
    0 讨论(0)
  • 2021-01-06 04:53

    Put it in the constructor, not InitializeComponent(). Adding using directives to your main class source code file isn't a problem.

    0 讨论(0)
  • 2021-01-06 04:57

    From the description in your question, some things are not clear that may be needed in order to answer:

    1. What exactly isn't working? Do you fail at compile time or at run time?
    2. Can you show the code that does not compile, or does not work at run time?
    3. What do you mean when you say the assemblies are "un-embedded"?

    Basically, from what I understand, you have code that tries to use classes from the 2 assemblies. This code is static, meaning that the classes have to be known at compile time. Or in other words, you must have a reference to those 2 assemblies in order to compile code that uses types that are defined in them.

    I don't really understand what went wrong when you added those assemblies as a reference. If what bothered you is that you saw them being copied into the bin/debug directory, that still should not have prevented them from also being embedded in your main assembly. So to test, you can try manually deleting them from bin/debug, or maybe setting them to "copy local = false".

    One more thing - the error you encountered that mentioned "using" and "namespaces" wasn't really about namespaces. This error means that the compiler didn't find the types it needed. And that was probably because you removed the references to the 2 assemblies.

    0 讨论(0)
提交回复
热议问题