.net InstallUtil引发AssemblySignatureKeyAttribute的TypeLoadException

.net InstallUtil引发AssemblySignatureKeyAttribute的TypeLoadException,.net,windows-services,installutil,.net,Windows Services,Installutil,在开发计算机上,使用InstallUtil时没有错误,服务已成功安装。 我打算在另一台计算机上安装它(它安装了.Net 4.0),因此我将以下文件复制到目标目录: InstallUtil.exe InstallUtil.exe.config InstallUtilLib.dll 在管理模式下运行util后,出现以下异常: 未处理的异常:System.TypeLoadException:无法加载类型 来自程序集的“System.Reflection.AssemblySignatureKeyAt

在开发计算机上,使用InstallUtil时没有错误,服务已成功安装。
我打算在另一台计算机上安装它(它安装了.Net 4.0),因此我将以下文件复制到目标目录:

  • InstallUtil.exe
  • InstallUtil.exe.config
  • InstallUtilLib.dll
在管理模式下运行util后,出现以下异常:

未处理的异常:System.TypeLoadException:无法加载类型 来自程序集的“System.Reflection.AssemblySignatureKeyAttribute” 'mscorlib,版本=4.0.0.0,区域性=中性, PublicKeyToken=b77a5c561934e089'。在 System.ModuleHandle.ResolveType(RuntimeModule模块,Int32 typeToken, Int Ptr*typeInstArgs、Int32 TYPEINSTCUNT、IntPtr*methodInstArgs、, Int32 methodInst计数,ObjectHandleOnStack类型)位于 System.ModuleHandle.ResolveTypeHandleInternal(运行时模块模块, Int32 typeToken,RuntimeTypeHandle[]TypeInstanceContext, RuntimeTypeHandle[]在中遇到了hodInstantiationContext) System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken, 类型[]ge nericTypeArguments,类型[]genericMethodArguments)位于 System.Reflection.CustomAttribute.FilterCustomAttribute记录(CustomAttrib uteRecord caRecord,元数据导入作用域,程序集& LastAptCookAssembly,运行时模块decoratedModule,MetadataToken decoratedToken,运行时类型attributeFileRType,布尔值 mustBeInheritable、Object[]属性、IList derivedAttributes、, RuntimeType和attributeType,IRuntimeMethodInfo和ctor,布尔值& ctorHasParameters,Boolean&isVarArg)位于 System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decora TED模块、Int32装饰MetadataToken、Int32 pcaCount、, RuntimeType attributeFi FilterType,布尔值必须为Inheritable,IList 派生属性,布尔值为Decorate数据目标安全透明)
在 System.Reflection.CustomAttribute.GetCustomAttributes(运行时程序集 组件,运行时类型(caType) System.Reflection.RuntimeAssembly.GetCustomAttributes(类型 属性类型,布尔值继承)位于 System.Configuration.InstallUtil.Main(字符串[]args)

似乎连InstallUtil都无法启动,因此无法安装服务。
我应该检查什么?

能否尝试从C:\Windows\Microsoft.NET\Framework\v4.0.30319\或其他相关文件夹(在C:\Windows\Microsoft.NET内)运行“installutil.exe”


我认为,您看到的错误主要是由于.NET版本不匹配。

您是对的,我使用的是另一个版本,没有使用已经安装的版本。很好。作为旁注:我设法用sc.exe来代替这个。嘿。。谢谢sc.exe可以工作。但是,如果您想以正确的方式执行,那么这不是最好的命令。请参考下面的问题,以获得Hans的合理解释。