[英]Is there a way to deploy both x86 and x64 versions of assemby with WCF service?
我有一個WCF服務,可同時部署到IIS的x86和x64實例。 服務本身是為AnyCPU編譯的。 該服務使用C ++程序集,這兩種位都有。 兩個位的名稱都相同(foo.dll)
有沒有辦法同時部署兩種類型的位,並讓IIS / WCF即時找出需要什么呢? 現在,弄清楚要部署什么是一個噩夢。
有沒有更好的辦法?
這個怎么樣?
public void LoadAssembly()
{
AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
var a = Assembly.Load("foo");
Type myType = a.GetType("Example");
// Get the method to call.
MethodInfo myMethod = myType.GetMethod("MethodA");
// Create an instance.
object obj = Activator.CreateInstance(myType);
// Execute the method.
myMethod.Invoke(obj, null);
}
private System.Reflection.Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
{
if (IntPtr.Size == 4)
{
// return your 32-bit.
}
else if (IntPtr.Size == 8)
{
// return your 64-bit.
}
}
有用的鏈接:
http://msdn.microsoft.com/en-us/library/system.appdomain.assemblyresolve.aspx http://msdn.microsoft.com/en-us/library/25y1ya39.aspx
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.