从另一个项目添加库后,Xamarin.Forms项目中断 [英] Xamarin.Forms Project breaks after adding Library from another Project

查看:108
本文介绍了从另一个项目添加库后,Xamarin.Forms项目中断的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想开始实现一个移动跨平台应用程序,该应用程序应使用XamarinForms调用现有的WCF服务.我对整个Xamarin还是很陌生,所以也许这是一个非常简单的解决方案.

所以我要做的是创建一个新的Xamarin.Forms便携式项目,其中包括所有Droid,iOS项目和其他内容.在图书馆项目中,我添加了一个新的Content-Page,编写了一些虚拟的"hello world"代码和startet,其作用就像是一种魅力.

当我想添加在WPF应用程序中使用过的现有库(也连接到所述WCF服务)时出现问题.在其中,我实现了一个服务代理类,希望在我的xamarin应用程序中重用.

添加库之后,Visual Studio似乎发疯了,并告诉我找不到在我的xaml中定义的InitializeComponents方法以及所有标签和内容.再次从引用中删除库后,错误保持不变.奇怪的是,我仍然可以运行该应用程序.

从项目设置中可以看出,xamarin应用程序将使用.NET 4.5进行构建,因此我也将库重新编译为4.5,但似乎并没有达到目的.是因为我在我的库中使用了一些不受支持的类(例如System.ServiceModel?)

也许有人对此行为有更多了解,可以给我提示!

感谢您的帮助!

欢呼

解决方案

这也发生在我身上.症状完全相同. xaml.cs文件在编辑器中显示错误,而项目本身可以编译并正常运行.但就我而言,我没有注意到任何特定的触发因素.我的意思是,在我向项目中添加库之后,这并没有特别发生.

最初,我注意到在编辑相应的XAML文件并单击 CTRL + S 后,错误消失了.原来,当我不需要编辑XAML时(肯定不想进行虚假编辑,例如添加空格等)时,调用运行自定义工具"(右键单击>运行自定义) XAML文件上的工具也可以正常工作.

I wanted to start implementing a mobile cross-plattform application which should call an existing WCF-Service with XamarinForms. I'm pretty new to the whole Xamarin thing, so maybe its a pretty easy solution.

So what I did was creating a new Xamarin.Forms Portable Project which includes all the Droid, iOS project and stuff. In the library project I added a new Content-Page, wrote some dummy "hello world" code and startet, works just like a charm.

The problem comes when I want to add an existing library that I've used in a WPF application that also connects to the said WCF service. In there I've implemented a service proxy class that I wanted to reuse in my xamarin application.

After I add the Library, Visual Studio just seems to go crazy and tells me that the InitializeComponents Method and all the labels and stuff I defined in my xaml couldn't be found. After deleting the library from the references again, the errors just stay the same. Strange thing is that I can run the app anyways.

From the project settings it says that the xamarin app is going to build with .NET 4.5, so I recompiled my library also to 4.5, but doesn't seem to do the trick. Is it because I use some classes in my library that are not supported (e.g. System.ServiceModel?)

Maybe someone a bit more about this behaviour, and can give me a hint!

Thanks for the help!

Cheers

解决方案

This happened to me as well. The symptoms are exactly the same; xaml.cs file is showing error in the editor, while the project itself compiles and runs just fine. But in my case, I didn't notice any particular trigger. I mean, in it isn't particularly happened after I added a library to the project.

Initially, I noticed the error was gone after I edited the corresponding XAML file and then hit CTRL+S. Turned out that, when I am not in the need to edit the XAML (and surely don't want to make a fake edit like adding whitespace etc.), invoking "Run Custom Tool" (right-click > run custom tool) on the XAML file works as well.

这篇关于从另一个项目添加库后,Xamarin.Forms项目中断的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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