Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
2
Question by nilcheck · Mar 03, 2017 at 02:14 PM · c#dllassembly

Unable to debug dynamically loaded assembly DLL that was loaded via Assembly.load() in Unity 5.5.1f1(64 bit)

I am loading an assembly as follows:

 var bytes = File.ReadAllBytes("E:/Code/Projects/MyUtilities/bin/Debug/MyUtilities.dll");
 Assembly loadedAssembly = Assembly.Load(bytes);

The assembly is loaded fine and I can call functions with invoke: System.Type type = loadedAssembly.GetType("DLLTest.MyUtilities");

             FieldInfo field = type.GetField("c");               

             Debug.Log(field.GetValue(null));

             // get the method
             MethodInfo method = type.GetMethod("test", BindingFlags.Public | BindingFlags.Static);
             object[] args = new object[1];
             args[0] = 2;
             var result = method.Invoke(null, args).ToString(); // assuming it doesn't take parameters

When I add the DLL project into the UNity solution and set a break point in the DLL project its not hit. The PDB is right beside the DLL. I have tried to keep it beside Library\ScriptAssemblies\Assembly-CSharp.dll as well. Still the breakpoint is not hit in the DLL code.

Tried all solution mentioned here: http://stackoverflow.com/questions/1295807/debug-dynamically-loaded-assembly-in-visual-studio-net?noredirect=1&lq=1

Does it have to be a mdb file rather than a PDB file?

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image nilcheck · Mar 02, 2017 at 06:49 PM 0
Share

I am using .Net version 3.5 for the DLL. After the project is built as a dll and pdb, I tried pdb2mdb.exe but it gives the following error:

Unhandled Exception: System.BadImageFormatException: Invalid PE file File name: 'E:\Code\Projects\$$anonymous$$yUtilities\bin\Debug\$$anonymous$$yUtilities.pdb' ---> $$anonymous$$ono.Cecil.Binary.ImageFormatException: Invalid PE File Signature at $$anonymous$$ono.Cecil.Binary.ImageReader.VisitDOSHeader(DOSHeader header) at $$anonymous$$ono.Cecil.Binary.Image.Accept(IBinaryVisitor visitor) at $$anonymous$$ono.Cecil.Binary.ImageReader.Read(String file) at $$anonymous$$ono.Cecil.Binary.ImageReader.Read(String file) at $$anonymous$$ono.Cecil.AssemblyFactory.GetAssembly(String file) at Pdb2$$anonymous$$db.Driver.$$anonymous$$ain(String[] args)

avatar image nilcheck · Mar 03, 2017 at 12:55 PM 0
Share

Ok, so what did work is placing the DLL and PDB in the Assets/plugins folder of the Unity project. But why do I need to do this. The PDB is also present where the DLL is compiled at E:/Code/Projects/$$anonymous$$yUtilities/bin/Debug/$$anonymous$$yUtilities.dll

Is it necessary to have a post build copy of the DLL and PDB into the Assets/plugins folder?

Can't I simply tell Unity to search for DLL assets at E:/Code/Projects/$$anonymous$$yUtilities/bin/Debug/ as well?

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Windows Phone 8.1 Assembly 0 Answers

Using a DLL assembly on Mac 2 Answers

When I build my game it gives me this error 'Assets/Builds/Build_0.01_Data/Managed/Assembly-CSharp.dll' shouldn't be queried by IsAssemblyCompatible, missing IsInternalOrCompiledAssembly check ? 2 Answers

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges