添加 .NET Framework DLL 作为对 Windows 商店应用程序的引用 [英] Adding .NET Framework DLL as reference to windows store app

查看:25
本文介绍了添加 .NET Framework DLL 作为对 Windows 商店应用程序的引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个 Windows 商店应用程序项目,我想在其中读取来自 National Instruments DAQ 的简单温度测量数据.但是,DAQ 的 DLL 库采用 .NETFramework 4.0 格式,当将其添加为我的 windows 商店应用程序项目的引用时,我收到以下错误:项目以 '.NetFramework' 为目标,而文件引用以 '.NetCore 为目标'"

I'm working on a windows store app project where I want to read a simple temperature measurement data from a National Instruments DAQ. However the DLL library for the DAQ is in .NETFramework 4.0 format and when adding this as reference to my windows store app project I get the following error: "The project targets ‘.NetFramework’ while the file reference targets ‘.NetCore’"

在网上搜索,我发现 Windows 商店应用程序必须仅使用对另一个 .NETCore 或 Portable Library 二进制文件的引用,它不能引用完整的 .NET 4.0 库.我想有很多人有类似的问题,所以我想知道那里有什么绕行技巧吗?

Searching the net, I found out that windows store app must use references to another .NETCore or Portable Library binary only, it cannot reference a full .NET 4.0 library. I guess there is many people who have similar problems,so I wonder if there is any walk around tricks out there?

推荐答案

如果你坚持使用别人提供的库,并且如果试图游说他们制作可移植版本的尝试不太可能成功,那么关于您唯一能做的就是找到其他地方来托管 DLL,然后与托管它的任何东西进行通信.例如,在某些情况下,可以编写一个基于 ASP.NET Web API 的服务,该服务将能够使用完整的 .NET Framework,从而能够使用 DLL.

If you're stuck with using a library supplied by someone else, and if attempts to lobby them to produce a portable version are unlikely to succeed, then about the only thing you can do is find somewhere else to host the DLL, and then communicate with whatever is hosting it. For example, for some scenarios it may be possible to write, say, an ASP.NET Web API based service, which will be able to use the full .NET Framework and will thus be able to use the DLL.

显然,这以一个问题换另一个问题:您现在需要一台可以为您运行 Web 服务的机器.(不幸的是,我相信微软并不正式支持在运行 Windows Store 应用程序的同一台机器上运行该 Web 应用程序.您也许可以让它在您的开发盒上运行,但您将无法部署Web 应用程序本身通过 Windows 应用商店.)

Obviously, this trades one problem for another: you now need to have a machine which can run a web service for you. (And unfortunately, I believe Microsoft does not officially support running that web app on the same machine that's running the Windows Store app. You may be able to get it to work on your dev box, but you'll not be able to deploy the web app itself via the Windows Store.)

这里没有捷径可走 - 您必须编写一个层,通过 HTTP 服务公开您需要的所有内容,以及使用这些服务的客户端代码.您还需要考虑如何保护对服务的访问.

And there's no easy path here - you'll have to write a layer exposing everything you need via HTTP services, and client-side code to consume those services. And you'll also need to think about how to to secure access to the service.

向您的供应商恳求可能更容易...

It may be easier to plead with your supplier...

理论上,如果库没有使用核心 .NET 配置文件之外的任何内容,那么您可以使用 ILDASM 和 ILASM 反编译并重新编译代码,将其转换为可移植库在这样做之前.但是,如果它是商业代码,这很可能会违反您的许可协议,并且在任何情况下都很可能不起作用.

In theory, if it so happens that the library isn't using anything outside of the core .NET profile, then you could use ILDASM and ILASM to de-compile and re-compile the code, converting it to a portable library before doing so. However, this is quite likely to breach your license agreement if it's commercial code, and in any case, is quite likely not to work.

这篇关于添加 .NET Framework DLL 作为对 Windows 商店应用程序的引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆