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:

[STAThread]
  static void Main()
  {
     AppDomain.CurrentDomain.AssemblyResolve += CurrentDomainOnAssemblyResolve;

      Application.EnableVisualStyles();
      Application.SetCompatibleTextRenderingDefault(false);
      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