Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7708823
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T00:42:41+00:00 2026-06-01T00:42:41+00:00

I have a strange situation in regards to xml serialization… If I run MyApp.exe

  • 0

I have a strange situation in regards to xml serialization…

If I run MyApp.exe (.NET 2.0 WinForms app) with properly generated MyApp.XMLSerializers.dll all is well and the serialization is fast (no serialization assemblies are generated at runtime, because serializers dll is found and is behaving).

Now, if I embed MyApp.exe as a resource in MyOtherManagedApp.exe (also .net 2.0) and execute the original app from inside as follows…

pasm = System.Reflection.Assembly.Load(MyOtherManagedApp.Properties.Resources.MyAppExeBinary);
Type type = pasm.GetType("MyApp.MyModule");
type.InvokeMember("Main", BindingFlags.Default | BindingFlags.InvokeMethod | BindingFlags.Static | BindingFlags.NonPublic,  null, null, new object[] {args});

… the original app loads and runs just fine, except for serialization part:

  1. If MyApp.XMLSerializers.dll is present in the working directory of MyOtherManagedApp, I get an error stating that MyApp.exe assembly cannot be found (the error is thrown by autogenerated MyApp.XMLSerializers.dll which for some strange reason, inspite of the fact that not only MyApp assembly has been loaded but is in fact executing, fails to find it).

  2. If MyApp.XMLSerializers.dll is NOT present in the working directory, no errors occur, but serialization assemblies are now being generated at run time which result in a big performance hit.

So, my question is why does it not work as it should? Namely, why MyApp.XMLSerializers.dll works perfectly if the serialization is started by MyApp.exe when it’s running by itself; whereas if it was started via Assembly.Load and InvokeMember from a different assembly, MyApp.XMLSerializers.dll complaints that it cannot find the very same MyApp assembly which has been dynamically loaded and is now running?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T00:42:42+00:00Added an answer on June 1, 2026 at 12:42 am

    I found the solution for this specific problem. The solution is to handle AppDomain.CurrentDomain.AssemblyResolve event for BOTH MyApp.XMLSerializers.dll AND MyApp.exe (the one which is embedded as a resource) INSIDE MyApp.exe!

    If e.Name.StartsWith(XMLSerializersAssemblyName) Then 'MyApp.XMLSerializers.dll lookup
       Return Assembly.LoadFile(MyOtherManagedApp_EXEFolder + "\" + XMLSerializersAssemblyName + ".dll")
    ElseIf e.Name = Assembly.GetExecutingAssembly.FullName Then 'MyApp.exe lookup
       Return Assembly.GetExecutingAssembly
    End If
    

    This way MyApp.XMLSerializers.dll is found and is properly loaded, and more importantly the MyApp.XMLSerializers.dll can the find the embedded MyApp.exe (which is not present anywhere as a file).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a strange situation here. In my android app, I have a layout
I have the next very strange situation and problem: .NET 4.0 application for diagram
I am new to VB.net and facing a strange situation. I have a structure
I have a strange situation. I have created a data model visually and generated
I have a strange situation in my .NET CF 3.5 Windows Mobile 6.5 application.
I have a strange situation on a production server. Connection for asp.net get queued
I have run into a strange situation where I need to float two elements.
I have a strange situation: in a .NET CF project there is a class
I have a strange situation. I have a website where hyperlinks are dynamically generated
i have a SEAM 2 application and i have a strange situation. I'm developing

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.