Emdeded resources with DevExpress WinForm

I am trying to create an exe with embedded resources. Everything works fine, but if the DevExpress.Utils.dll is not in the same folder like the .exe the application crashes!
Although all dll files are included as embedded resources and I reference to these.
The strange thing is it is only the DevExpress.Utils.dll.
Dlls that are not found I am loading with this:

  static void Main()
     AppDomain.CurrentDomain.AssemblyResolve += CurrentDomainOnAssemblyResolve;

      Application.Run(new MyForm());

  private static Assembly CurrentDomainOnAssemblyResolve(object sender, ResolveEventArgs args)
    // the ddls are in a lib folder.
     String resourceName = "MyApplication." + "lib." + new AssemblyName(args.Name).Name + ".dll";

     using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName))
        if (stream != null)
           Byte[] assemblyData = new Byte[stream.Length];

           stream.Read(assemblyData, 0, assemblyData.Length);

           return Assembly.Load(assemblyData);
     return null;

Source: dll

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.