.net 4.0 Can';t在GAC中为.NET4服务器2008 R2注册程序集
我有一个强大的命名程序集,其中包含可以在同一台计算机上托管的多个应用程序(IIS中的WCF服务)之间共享的模型类 我想将它添加到GAC,而不是每个服务在.net 4.0 Can';t在GAC中为.NET4服务器2008 R2注册程序集,.net-4.0,windows-server-2008,gac,gacutil,.net 4.0,Windows Server 2008,Gac,Gacutil,我有一个强大的命名程序集,其中包含可以在同一台计算机上托管的多个应用程序(IIS中的WCF服务)之间共享的模型类 我想将它添加到GAC,而不是每个服务在Bin文件夹中都有自己的DLL副本 我正在使用.NET4:Microsoft(R).NET全局程序集缓存实用程序的gacutil.exe。版本4.0.30319.1版权所有(c)Microsoft Corporation。保留所有权利。 DLL已在GAC中注册,但最终位于C:\Windows\Assembly(GAC 2.0)-而不是C:\Win
Bin
文件夹中都有自己的DLL副本
我正在使用.NET4:Microsoft(R).NET全局程序集缓存实用程序的gacutil.exe。版本4.0.30319.1版权所有(c)Microsoft Corporation。保留所有权利。
DLL已在GAC中注册,但最终位于C:\Windows\Assembly
(GAC 2.0)-而不是C:\Windows\Microsoft.NET\Assembly
(GAC 4)
当我在GAC中注册DLL并将其从Bin
文件夹中删除时,我的应用程序会出现以下故障:
无法加载文件或程序集“MyCompany.Enterprise.BOM”或其依赖项之一。系统找不到指定的文件。在System.Reflection.RuntimeAssembly.\n加载(AssemblyName文件名、字符串代码库、证据assemblySecurity、RuntimeAssembly位置提示、StackScrawMark和stackMark、Boolean throwOnFileNotFound、Boolean For Inspection、Boolean suppressSecurityChecks).
注意:Server2008R2是64位的,程序集是为MSIL.NET4.0构建的。
我正在使用Windows SDK v7.1附带的gacutil.exe,它位于NETFX 4.0 Tools
文件夹中
我会错过什么?我想不出任何替代方案,所以欢迎提出任何想法
编辑(清单):
从清单中可以看出,Dll是运行时2.0版本,因此即使是4.0的gacutil也会将其放在2.0 GAC中 清单是在编译时创建的,因此您的项目和/或编译设置一定有问题
我假设您使用Visual Studio,因此请查看“应用程序”选项卡中的项目(而非解决方案)设置。您可以使用ildasm.exe查看程序集并在此处发布清单的开头吗?@TToni-我看到清单中有v2.0版的元数据-如何将其更改为4.0版?这是在编译时生成的吗?谢谢!就是这样-该项目被配置为以.NET3.5为目标。DLL在只安装了.NET 4.0的计算机上运行良好,但必须位于Bin文件夹中。它在.NET2和.NET3.5以及.NET4应用程序之间共享,因此需要保持.NET2.0的状态。
// Metadata version: v2.0.50727
.assembly extern mscorlib
{
.publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
.ver 2:0:0:0
}
.assembly extern System.Runtime.Serialization
{
.publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
.ver 3:0:0:0
}
.assembly HCS.Enterprise.BOM
{
.custom instance void [mscorlib]System.Runtime.InteropServices.GuidAttribute::.ctor(string) = ( 01 00 24 63 31 34 64 39 31 65 32 2D 30 35 31 65 // ..$c14d91e2-051e
2D 34 66 65 31 2D 38 62 37 30 2D 61 36 36 33 66 // -4fe1-8b70-a663f
39 61 37 62 34 33 35 00 00 ) // 9a7b435..
.custom instance void [mscorlib]System.Reflection.AssemblyKeyFileAttribute::.ctor(string) = ( 01 00 20 43 3A 5C 48 43 53 2E 45 6E 74 65 72 70 // .. C:\HCS.Enterp
72 69 73 65 5C 4B 65 79 5C 48 43 53 4B 65 79 2E // rise\Key\HCSKey.
73 6E 6B 00 00 ) // snk..
// --- The following custom attribute is added automatically, do not uncomment -------
// .custom instance void [mscorlib]System.Diagnostics.DebuggableAttribute::.ctor(valuetype [mscorlib]System.Diagnostics.DebuggableAttribute/DebuggingModes) = ( 01 00 02 00 00 00 00 00 )
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilationRelaxationsAttribute::.ctor(int32) = ( 01 00 08 00 00 00 00 00 )
.custom instance void [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() = ( 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx
63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 ) // ceptionThrows.
.custom instance void [mscorlib]System.Reflection.AssemblyFileVersionAttribute::.ctor(string) = ( 01 00 07 31 2E 30 2E 30 2E 30 00 00 ) // ...1.0.0.0..
.custom instance void [mscorlib]System.Reflection.AssemblyTitleAttribute::.ctor(string) = ( 01 00 12 48 43 53 2E 45 6E 74 65 72 70 72 69 73 // ...HCS.Enterpris
65 2E 42 4F 4D 00 00 ) // e.BOM..
.custom instance void [mscorlib]System.Reflection.AssemblyDescriptionAttribute::.ctor(string) = ( 01 00 00 00 00 )
.custom instance void [mscorlib]System.Reflection.AssemblyConfigurationAttribute::.ctor(string) = ( 01 00 00 00 00 )
.custom instance void [mscorlib]System.Reflection.AssemblyCompanyAttribute::.ctor(string) = ( 01 00 0E 48 6F 72 69 7A 6F 6E 2D 42 43 42 53 4E // ...HN
4A 00 00 ) // J..
.custom instance void [mscorlib]System.Reflection.AssemblyProductAttribute::.ctor(string) = ( 01 00 12 48 43 53 2E 45 6E 74 65 72 70 72 69 73 // ...HCS.Enterpris
65 2E 42 4F 4D 00 00 ) // e.BOM..
.custom instance void [mscorlib]System.Reflection.AssemblyCopyrightAttribute::.ctor(string) = ( 01 00 20 43 6F 70 79 72 69 67 68 74 20 C2 A9 20 // .. Copyright ..
48 6F 72 69 7A 6F 6E 2D 42 43 42 53 4E 4A 20 32 // H2
30 31 30 00 00 ) // 010..
.custom instance void [mscorlib]System.Reflection.AssemblyTrademarkAttribute::.ctor(string) = ( 01 00 00 00 00 )
.custom instance void [mscorlib]System.Runtime.InteropServices.ComVisibleAttribute::.ctor(bool) = ( 01 00 00 00 00 )
.publickey = (00 24 00 00 04 80 00 00 94 00 00 00 06 02 00 00 // .$..............
00 24 00 00 52 53 41 31 00 04 00 00 01 00 01 00 // .$..RSA1........
3B 65 DD 3B C7 49 A7 F4 C9 50 BE 27 F9 62 B6 54 // ;e.;.I...P.'.b.T
D1 26 7B DC 5B EF C1 02 59 E8 77 D4 3D F5 2F 50 // .&{.[...Y.w.=./P
94 22 AC C3 B7 07 71 A4 99 D4 FF 10 ED 05 6D 70 // ."....q.......mp
9A 9D 99 DC 33 1F 8A 3F A5 77 2E C5 5F 9D 35 15 // ....3..?.w.._.5.
BA 54 47 47 C2 8B 13 8C 57 57 C6 1E F5 AB 7B D5 // .TGG....WW....{.
B8 87 DD 4A F3 69 01 B2 6B C8 88 99 04 09 19 FC // ...J.i..k.......
5E 51 7E 2A B9 B5 03 80 C9 A3 EA ED EF B8 EC BF // ^Q~*............
EB 97 30 EC D9 E4 36 7C 0F 64 B7 27 9D 29 0D C5 ) // ..0...6|.d.'.)..
.hash algorithm 0x00008004
.ver 1:0:0:0
}
.module HCS.Enterprise.BOM.dll
// MVID: {D4D8B566-6B0D-4F8D-ABD4-C3A1339B4F84}
.imagebase 0x00400000
.file alignment 0x00000200
.stackreserve 0x00100000
.subsystem 0x0003 // WINDOWS_CUI
.corflags 0x00000009 // ILONLY
// Image base: 0x031B0000