Options

Microsoft.Office.Interop.Excel referense error?

anders.isacsonanders.isacson Posts: 12 Bronze 2
edited January 20, 2015 12:28PM in SmartAssembly
I get the error System.TypeLoadException: Could not load type '#Zeh.#Igh' from assembly 'MyMainAssemby... The type is marked as eligible for type equivalence, but it is not marked as public.

'#Zeh.#Igh' is 'Microsoft.Office.Interop.Excel.AppEvents_Event'.
The error occurs in a dll that is merged into the main assembly.
Microsoft.Office.Interop.Excel is not in the list of dependencies when I view the obfuscation project in SmartAssembly Professional version 6.8.0.121

Why is code in my merged dll trying to access Microsoft.Office.Interop.Excel? I have a copy of Microsoft.Office.Interop.Excel.dll installed in the same directory as my obfuscated executable and expect it to be used.

Comments

  • Options
    Jessica RJessica R Posts: 1,319 Rose Gold 4
    Hi Anders,

    Thanks for your post!

    I believe this will happen if you have "Embed interop types" enabled for the Microsoft.Office.Interop.Excel reference.

    Could you kindly either set the option to false, rebuild from VS, and then build again from SmartAssembly? Alternatively, if you go to the obfuscation section in the SmartAssembly UI and click on the "Exclusions" link button, you should see a namespace added for Microsoft.Office.Interop.Excel--kindly exclude the entire namespace and then build again to make sure the error is resolved.

    Please let me know how you get on!

    Jessica Ramos | Product Support Engineer | Redgate Software

    Have you visited our Help Center?


  • Options
    Thank you Jessica,
    For some reason "Embed interop types" was enabled in VS. Setting it to false solved the problem.
    Regards @nders
  • Options
    Microsoft.Office.Interop.Excel is not in the list of dependencies when I view the obfuscation project in SmartAssembly Professional version 6.8.0.121

    Why is code in my merged dll trying to access Microsoft.Office.Interop.Excel? I have a copy of Microsoft.Office.Interop.Excel.dll installed in the same directory as my obfuscated executable and expect it to be used.
    aliiiiii
  • Options
    Jessica RJessica R Posts: 1,319 Rose Gold 4
    Hi ihaseeb,

    I'ts actually VS that has put the interop assembly into the main assembly. Just a bit more on this: when you enable the "Embed interop types" option from within Visual Studio, it embeds the types into your main assembly and SmartAssembly will then include them in obfuscation. However, your application needs to find those types by their original names, so they should be excluded. If not, it will give the "type is marked as eligible for type equivalence, but it is not marked as public" as you are seeing.

    There are two workarounds for this error:

    1) Set the "Embed interop types" option to false, rebuild from VS, and then build again from SmartAssembly

    or

    2) From the obfuscation section in the SmartAssembly UI, if you click on the "Exclusions" link button, you should see a namespace added for the interop type--you can exclude the entire namespace and then build again to make sure the error is resolved (you can confirm the interop type by obfuscating using ASCII characters, then entering the obfuscated type in the error message into the decode stack trace feature)

    I hope this information helps!

    Jessica Ramos | Product Support Engineer | Redgate Software

    Have you visited our Help Center?


Sign In or Register to comment.