【问题标题】:Is there a way to deploy both x86 and x64 versions of assemby with WCF service?有没有办法使用 WCF 服务部署 x86 和 x64 版本的程序集?
【发布时间】:2013-07-18 18:07:16
【问题描述】:

我有一个 WCF 服务,它部署到 IIS 的 x86 和 x64 实例。服务本身是为 AnyCPU 编译的。该服务使用 C++ 程序集,它有两种不同的位数。两种位的名称相同(foo.dll)

有没有一种方法可以同时部署这两种位数并让 IIS/WCF 即时确定需要什么?现在,弄清楚要部署什么有点像噩梦。

有没有更好的办法?

【问题讨论】:

  • 您目前如何加载 c++ dll?
  • @SamShiles 接口是相同的,所以只有 2 个构建。这很好用。但是当我从我的工作站部署到某个开发箱时,总是会混淆什么是什么位。

标签: c# .net wcf iis 64-bit


【解决方案1】:

这个怎么样?

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

【讨论】:

    猜你喜欢
    • 2011-03-28
    • 2014-12-01
    • 2011-12-21
    • 1970-01-01
    • 1970-01-01
    • 2017-11-23
    • 1970-01-01
    • 1970-01-01
    • 2018-05-31
    相关资源
    最近更新 更多