File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change 4
4
using System . IO ;
5
5
using System . Linq ;
6
6
using System . Reflection ;
7
+ using System . Reflection . Metadata ;
7
8
using System . Runtime . Loader ;
8
9
using System . Text ;
9
10
using System . Text . RegularExpressions ;
@@ -161,7 +162,20 @@ private Assembly Compile(IEnumerable<string> sources)
161
162
var references = AppDomain . CurrentDomain . GetAssemblies ( )
162
163
. Concat ( new [ ] { Assembly . GetExecutingAssembly ( ) , } )
163
164
. Where ( x => x . IsDynamic == false )
164
- . Select ( x => MetadataReference . CreateFromFile ( x . Location ) ) ;
165
+ . Select ( x => {
166
+ if ( ! string . IsNullOrEmpty ( x . Location ) )
167
+ {
168
+ return MetadataReference . CreateFromFile ( x . Location ) ;
169
+ }
170
+ else
171
+ {
172
+ unsafe
173
+ {
174
+ x . TryGetRawMetadata ( out byte * blob , out int length ) ;
175
+ return AssemblyMetadata . Create ( ModuleMetadata . CreateFromMetadata ( ( IntPtr ) blob , length ) ) . GetReference ( ) ;
176
+ }
177
+ }
178
+ } ) ;
165
179
var options = new CSharpCompilationOptions ( OutputKind . DynamicallyLinkedLibrary ) ;
166
180
var compilation = CSharpCompilation . Create ( name )
167
181
. WithOptions ( options )
Original file line number Diff line number Diff line change 23
23
<Title >Virtual Desktop API for C#</Title >
24
24
<RepositoryType >git</RepositoryType >
25
25
<PackageReleaseNotes >$(PublishReleaseNotes)</PackageReleaseNotes >
26
+ <AllowUnsafeBlocks >true</AllowUnsafeBlocks >
26
27
</PropertyGroup >
27
28
28
29
<PropertyGroup Condition =" '$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net6.0-windows10.0.19041.0|AnyCPU'" >
You can’t perform that action at this time.
0 commit comments