我有delphi应用程序(hostproject.exe),我想使用注册免费技术消耗.net com对象(NetSide.dll)。
当应用程序启动时,显示并排配置错误和sxtrace日志:
无法解析参考mscorlib,publicKeyToken =" b77a5c561934e089", 版本=" 4.0.0.0"
hostproject.exe.manifest
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity type="win32" name="client" version="1.0.0.0" />
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32" name="NetSide.sxs" version="1.0.0.0" processorArchitecture="msil"/>
</dependentAssembly>
</dependency>
</assembly>
NetSide.sxs.manifest
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity type="win32" name="NetSide.sxs" version="1.0.0.0" processorArchitecture="msil"/>
<clrClass clsid="{E6C4A866-F58C-415E-9745-E0E7812B4386}" progid="NetSide.Class1" threadingModel="Both" name="NetSide.Class1" runtimeVersion="v4.0.30319"/>
<file name="NetSide.dll" hashalg="SHA1"/>
<dependency>
<dependentAssembly>
<assemblyIdentity name="mscorlib" version="4.0.0.0" processorArchitecture="x86" publicKeyToken="b77a5c561934e089"/>
</dependentAssembly>
</dependency>
</assembly>
下面的sxstrace日志:
=================
Begin Activation Context Generation.
Input Parameter:
Flags = 0
ProcessorArchitecture = Wow32
CultureFallBacks = en-US;en
ManifestPath = G:\Debug\HostProject.exe.Manifest
AssemblyDirectory = G:\Debug\
Application Config File =
-----------------
INFO: Parsing Manifest File G:\Debug\HostProject.exe.Manifest.
INFO: Manifest Definition Identity is client11,type="win32",version="1.0.0.0".
INFO: Reference: NetSide.sxs,processorArchitecture="msil",type="win32",version="1.0.0.0"
INFO: Resolving reference NetSide.sxs,processorArchitecture="msil",type="win32",version="1.0.0.0".
INFO: Resolving reference for ProcessorArchitecture msil.
INFO: Resolving reference for culture Neutral.
INFO: Applying Binding Policy.
INFO: No binding policy redirect found.
INFO: Begin assembly probing.
INFO: Did not find the assembly in WinSxS.
INFO: Attempt to probe manifest at G:\Debug\NetSide.sxs.DLL.
INFO: Attempt to probe manifest at G:\Debug\NetSide.sxs.MANIFEST.
INFO: Manifest found at G:\Debug\NetSide.sxs.MANIFEST.
INFO: End assembly probing.
INFO: Resolving reference NetSide.sxs.mui,language="*",processorArchitecture="msil",type="win32",version="1.0.0.0".
INFO: Resolving reference for ProcessorArchitecture msil.
INFO: Resolving reference for culture en-US.
INFO: Applying Binding Policy.
INFO: No binding policy redirect found.
INFO: Begin assembly probing.
INFO: Did not find the assembly in WinSxS.
INFO: Did not find manifest for culture en-US.
INFO: End assembly probing.
INFO: Resolving reference for culture en.
INFO: Applying Binding Policy.
INFO: No binding policy redirect found.
INFO: Begin assembly probing.
INFO: Did not find the assembly in WinSxS.
INFO: Did not find manifest for culture en.
INFO: End assembly probing.
INFO: Parsing Manifest File G:\Debug\NetSide.sxs.MANIFEST.
INFO: Manifest Definition Identity is NetSide.sxs,processorArchitecture="msil",type="win32",version="1.0.0.0".
INFO: Reference: mscorlib,publicKeyToken="b77a5c561934e089",version="4.0.0.0"
INFO: Resolving reference mscorlib,publicKeyToken="b77a5c561934e089",version="4.0.0.0".
INFO: Resolving reference for ProcessorArchitecture mscorlib,publicKeyToken="b77a5c561934e089",version="4.0.0.0".
INFO: Resolving reference for culture Neutral.
INFO: Applying Binding Policy.
INFO: No publisher policy found.
INFO: No binding policy redirect found.
INFO: Begin assembly probing.
INFO: Did not find the assembly in WinSxS.
INFO: Attempt to probe manifest at C:\Windows\assembly\GAC\mscorlib\4.0.0.0__b77a5c561934e089\mscorlib.DLL.
INFO: Attempt to probe manifest at G:\Debug\mscorlib.DLL.
INFO: Attempt to probe manifest at G:\Debug\mscorlib.MANIFEST.
INFO: Attempt to probe manifest at G:\Debug\mscorlib\mscorlib.DLL.
INFO: Attempt to probe manifest at G:\Debug\mscorlib\mscorlib.MANIFEST.
INFO: Did not find manifest for culture Neutral.
INFO: End assembly probing.
ERROR: Cannot resolve reference mscorlib,publicKeyToken="b77a5c561934e089",version="4.0.0.0".
ERROR: Activation Context generation failed.
End Activation Context Generation.
答案 0 :(得分:0)
从NetSide.sxs和 public byte[] GetEncryptedStream(string jsonData)
{
byte[] dataBytes = System.Text.Encoding.UTF8.GetBytes(jsonData);
byte[] key = null;//GetKey() //I am assuming you arealy have your Key
//Call your encrypt function below
byte[] encryptedDataBytes = encrypt(dataBytes, key); // I am assuming your function returns byte array
return encryptedDataBytes;
}
public HttpResponseMessage GetHttpResponseMessage()
{
var result = new HttpResponseMessage(System.Net.HttpStatusCode.OK);
String jsonString = "your json data";
byte[] data = GetEncryptedStream(jsonString);
result.Content = new ByteArrayContent(data);
return result;
}
删除对mscorlib的依赖:
processorArchitecture