便携式类库不支持许多VB方法 [英] Portable Class Library not supporting many VB methods

查看:130
本文介绍了便携式类库不支持许多VB方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用VB.Net DLL并将其转换为便携式类库。一旦我把所有的类都移入了PCL的新项目,Visual Studio开始抛出许多常见的VB语法错误,我认为它仍然可以正常工作。一些例子:




  • LCase

  • InStr



  • 错误转到0

  • 错误



是否可能只有一些选项或包括我需要让这些工作?

解决方案

当使用便携式目标下载平台(.NET 4.0,Silverlight,Windows Phone,Xbox)时,我们不支持Microsoft.VisualBasic.dll中公开的大部分功能。 / p>

相反,我们利用嵌入式运行时功能。这将嵌入传统上在Microsoft.VisualBasic.dll中找到的某些功能,转化为生成的二进制本身。支持的功能在此页面的 / vbruntime * 部分下被调用: http://msdn.microsoft.com/en-us/library/bb531259.aspx



当定位.NET 4.5& Windows Store应用程序,然后您可以访问传统的Microsoft.VisualBasic.dll。



作为解决方法,帮助您转到便携式,您可以定义自己的模块,将旧的VB功能与其等效的网桥桥接起来。

 公共模块VisualBasicBridge 
公共函数LCase(值As String)As String

返回值.ToLower()
结束函数
结束模块

就On Error而言,我不知道有一个很好的方法来弥合,而不提供自己的Microsoft.VisualBasic实现,并通过/ vbruntime switch / msbuild属性。


I'm taking a VB.Net DLL and turning it into a Portable Class Library. Once I got all of the classes moved into the new project for the PCL, Visual Studio started throwing errors for a lot of common VB syntax that I thought would still work just fine. Some examples:

  • LCase
  • InStr
  • Left
  • Mid
  • On Error GoTo 0
  • Err

Is it possible there is just some option or include I need to have to get these to work?

解决方案

When using portable to target the down-level platforms (.NET 4.0, Silverlight, Windows Phone, Xbox), we do not support the majority of the features that are exposed within Microsoft.VisualBasic.dll.

Instead, we make use of the embedded runtime feature. This embeds certain functionality that would traditionally be found in Microsoft.VisualBasic.dll, into the resulting binary itself. The features that are supported are called out on this page, under the /vbruntime* section: http://msdn.microsoft.com/en-us/library/bb531259.aspx.

When targeting .NET 4.5 & Windows Store apps only, then you do get access to the traditional Microsoft.VisualBasic.dll.

As a workaround, to help you move to portable, you can define your own module that bridges the old VB functions to their .NET equivalents:

Public Module VisualBasicBridge
    Public Function LCase(value As String) As String

        Return value.ToLower()
    End Function
End Module

As far as On Error, I'm not aware of a good way to bridging that without providing your own implementation of Microsoft.VisualBasic, and passing that via the /vbruntime switch/msbuild property.

这篇关于便携式类库不支持许多VB方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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