0

I'm trying to use the POS for .NET library in a .NET 4.0 application and I'm running into some problems. The first was the 'CAS policy' exception that a lot of people seem to encounter. So I've added the NetFx40_LegacySecurityPolicy=true entry to my app.config file as Microsoft recommends.

A problem I'm seeing now though, is when I have the debugger attached and I try to construct a new PosExplorer, the constructor hangs. If the debugger is detached when I created it, everything seems to be fine (and I can re-attach at this point and everything works).

Does anybody have an idea as to what could be causing this behavior, and hopefully what I could do to correct it?

4

2 回答 2

0

我开始使用 Reflector Pro 调试 PoS 库,发现它卡在了这种方法中:

private static ServiceObjectCollection ScanFolder(string path, Dictionary<string, string> posAssemblies)
{
  Logger.Info("AssemblyLoader", "Scanning folder " + path + " for SO assemblies.");
  ServiceObjectCollection serviceobjects = new ServiceObjectCollection();
  DirectoryInfo info = new DirectoryInfo(path);
  Logger.Info("AssemblyLoader", "Enumerating files in " + path);
  foreach (FileInfo info2 in info.GetFiles())
  {
    LoadFile(info2, posAssemblies, serviceobjects);
  }
  Logger.Info("AssemblyLoader", "Leaving ScanFolder.");
  return serviceobjects;
}

它试图加载工作目录中的每个程序集以扫描 PoS 对象......它在尝试加载我们的应用程序也使用的旧托管 DirectX 库时挂起。

应用此问题的修复程序:从 .Net Framework 4.0 应用程序运行的托管 DirectX无法解决问题。我们已经使用这个技巧将 MDX 与 .NET 4 一起使用,但是我没有在这种情况下应用 app.config 设置,因为我正在编写一个独立的应用程序来熟悉 PoS……没想到我将尝试加载 DirectX :)

于 2011-04-27T00:13:18.910 回答
0

.NET Framework 4 及更高版本并不总是能很好地与早期版本的框架配合使用。一个常见问题是在创建 .NET 3.5 程序集的实例时 .NET 4.0 挂起。

要解决此问题,请将以下内容添加到您的 app.config:

<startup useLegacyV2RuntimeActivationPolicy ="true" ><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/></startup>
于 2013-04-26T08:13:52.360 回答