简体   繁体   English

尝试获取程序包的当前版本会导致错误APPX1706和APPX1704

[英]Trying to get the package current version causes errors APPX1706 and APPX1704

I have some troubles with Windows.ApplicationModel.Package class. 我对Windows.ApplicationModel.Package类有一些麻烦。

When I try to add the reference to Windows.ApplicationModel or when I'm getting the current package, 17000+ errors appears. 当我尝试将引用添加到Windows.ApplicationModel或获取当前程序包时,出现17000多个错误。

How I try to get the current package : 我如何尝试获取当前软件包:

var myPackage = Windows.ApplicationModel.Package.Current;

The kind of error I get : 我得到的那种错误:

error APPX1704: The file .winmd 'Windows.Foundation.UniversalApiContract.winmd' contains type 'Windows.Graphics.Effects.IGraphicsEffect'. 错误APPX1704:文件.winmd'Windows.Foundation.UniversalApiContract.winmd'包含类型'Windows.Graphics.Effects.IGraphicsEffect'。 The use of spacename Windows is reserved. Windows保留使用空间名。

Or 要么

error APPX1706: The .winmd file 'Windows.Foundation.UniversalApiContract.winmd' contains type 'Windows.Graphics.Effects.IGraphicsEffect' outside its root namespace 'Windows.Foundation.UniversalApiContract'. 错误APPX1706:.winmd文件“ Windows.Foundation.UniversalApiContract.winmd”在其根名称空间“ Windows.Foundation.UniversalApiContract”之外包含类型“ Windows.Graphics.Effects.IGraphicsEffect”。 Make sure that all public types appear under a common root namespace that matches the output file name. 确保所有公共类型都出现在与输出文件名匹配的公共根名称空间下。

Is there a solution to this problem or a better way to get the current version ? 是否有解决此问题的方法或获取当前版本的更好方法?

For the first problem I am a bit uncertain, but it is always good idea to reboot (ide, os, etc.), if this is not helping maybe reinstall the SDK, IDE. 对于第一个问题,我有点不确定,但是重新引导(如IDE,OS等)始终是个好主意,如果这不能帮助重新安装SDK,IDE。 I know this is not complete answer, it is just from experience. 我知道这不是完整的答案,仅凭经验即可。 The second error is saying that your namespaces are not consistent. 第二个错误是您的命名空间不一致。 It means that instead of having Example.Logic, Example.Domain, Example.Utils - you have something like Example.Logic, Test.Domain, Utils (inconsistency of namespaces). 这意味着您将拥有例如Example.Logic,Test.Domain,Utils(名称空间不一致),而不是拥有Example.Logic,Example.Domain,Example.Utils。

I found the source of the issue, it was due to the structure of the solution. 我发现了问题的根源,这是由于解决方案的结构所致。

Just like in a Xamarin application, we have a "Core" project that contains the application logic. 就像在Xamarin应用程序中一样,我们有一个“ Core”项目,其中包含应用程序逻辑。

We tried to use some Windows app specific namespaces in these shared classes, instead of creating an interface in the Core project and implementing it in the UWP project. 我们试图在这些共享类中使用一些Windows应用程序特定的名称空间,而不是在Core项目中创建接口并在UWP项目中实现该接口。

Xamarin代码共享

Removing the line with the reference to the Windows.ApplicationModel.Package class from the core project and move it to the UWP project resolved the issue. 从核心项目中删除对Windows.ApplicationModel.Package类的引用行,并将其移至UWP项目即可解决此问题。

Sorry for the lack of information on the original post. 抱歉,原帖信息不足。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM