question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Question] Can this be used to save a dynamic assembly to disk?

See original GitHub issue

As it is currently not possible to use ref emit AssemblyBuilder.Save from .NET Standard 2.0 - can this lib be used for that? I’m going to do code gen using ref emit, will I then be able to save the resulting assembly to disk using this?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8

github_iconTop GitHub Comments

2reactions
0xd4dcommented, Sep 21, 2019

I’ve opened a new issue https://github.com/0xd4d/dnlib/issues/308 . I don’t know when I’ve time to finish it, it’s not difficult, just a lot of code.

0reactions
per-samuelssoncommented, Sep 21, 2019

It’s not supported, you have to do it yourself, it’s what dnSpy does.

I see, thanks for clarifying.

There’s a nuget package (I’ve not tried it myself), see dotnet/corefx#4491 (comment)

Tried that before I tried this, and failed there too unfortunately. Failed on this:

https://github.com/Lokad/ILPack/issues/107#issuecomment-533771081

and that was reported some time ago, and don’t seem to be fixed.

So seems this story (saving generated assemblies to disk on net core) is kind of status quo since a few years back.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Is it possible to save a dynamic assembly to disk?
Is there a way to save dynamic assemblies to disk so that I can reflect them? EDIT / My Answer: Wow, it took...
Read more >
How Do I Emit And Save To Disk An Asembly Dynamically?
Save and provide an assembly filename,SimpleDyn. dll in this case. I have also tried to use other overloaded appDomain.
Read more >
AssemblyBuilder.Save Method (System.Reflection.Emit)
Saving a dynamic assembly to disk is only supported in .NET Framework. This method saves all non-transient dynamic modules defined in this dynamic...
Read more >
Creating a dynamis assembly and saving into disk
The following code snippet will create a dynamic assembly in the given name and save it into local disk. We can use this...
Read more >
System.Reflection.Emit.AssemblyBuilder.Save #15704
Our use case in Castle DynamicProxy is to write out dynamically created assemblies to disk so we can run peverify over the assembly...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found