如何在lightswitch应用程序中访问本地dll
我试图在Lightswitch应用程序中使用以下代码打印条形码
Imports System.Security Namespace LightSwitchApplication Public Class EditableAS_TempStickersGrid 'Declaration of Private Subroutine Private Declare Sub openport Lib "tsclib.dll" (ByVal PrinterName As String) Private Declare Sub closeport Lib "tsclib.dll" () Private Declare Sub sendcommand Lib "tsclib.dll" (ByVal command_Renamed As String) Private Declare Sub setup Lib "tsclib.dll" (ByVal LabelWidth As String, ByVal LabelHeight As String, ByVal Speed As String, ByVal Density As String, ByVal Sensor As String, ByVal Vertical As String, ByVal Offset As String) Private Declare Sub downloadpcx Lib "tsclib.dll" (ByVal Filename As String, ByVal ImageName As String) Private Declare Sub barcode Lib "tsclib.dll" (ByVal X As String, ByVal Y As String, ByVal CodeType As String, ByVal Height_Renamed As String, ByVal Readable As String, ByVal rotation As String, ByVal Narrow As String, ByVal Wide As String, ByVal Code As String) Private Declare Sub printerfont Lib "tsclib.dll" (ByVal X As String, ByVal Y As String, ByVal FontName As String, ByVal rotation As String, ByVal Xmul As String, ByVal Ymul As String, ByVal Content As String) Private Declare Sub clearbuffer Lib "tsclib.dll" () Private Declare Sub printlabel Lib "tsclib.dll" (ByVal NumberOfSet As String, ByVal NumberOfCopy As String) Private Declare Sub formfeed Lib "tsclib.dll" () Private Declare Sub nobackfeed Lib "tsclib.dll" () Private Declare Sub windowsfont Lib "tsclib.dll" (ByVal X As Short, ByVal Y As Short, ByVal fontheight_Renamed As Short, ByVal rotation As Short, ByVal fontstyle As Short, ByVal fontunderline As Short, ByVal FaceName As String, ByVal TextContent As String) Private Sub Print_Stickers_Execute() ' Write your code here. printSticker("244001", "", "test code", "") For Each sticker In AS_TempStickers 'code to print barcode Dim p As AS_ProductDetail = New AS_ProductDetail p.SerialNo = sticker.SerialNo p.dashCommerce_Store_Sku = sticker.dashCommerce_Store_Sku p.CurrentLocation = "STICKER" sticker.Delete() Me.Save() Next End Sub Private Sub printSticker(code1 As String, code2 As String, str1 As String, str2 As String) Dim B1 As String = code1 Dim WT1 As String = str1 'Connect to a printer and set up the parameters' Call openport("TSC TTP-244 Plus") Call setup("102", "64", "4.0", "7", "0", "2", "0") Call clearbuffer() Call sendcommand("DIRECTION 1") Call sendcommand("SET CUTTER OFF") ' Or the number of printout per cut' Call barcode("40", "300", "128", "80", "1", "0", "2", "2", B1) 'Print a text with Windows Arial font' Call windowsfont(120, 440, 40, 0, 0, 0, "ARIAL", WT1) 'The number of printout sets&copies' Call printlabel("1", "1") 'Disconnect with the printer' Call closeport() End Sub End Class End Namespace
我收到这个错误:
Methods must be security critical or security safe-critical to call native code.
我知道这是因为.net framework v4内置的安全性,我也尝试添加securitySafeCritical Attribute,但它似乎完全被忽略。
我究竟做错了什么?。 我是Silverlight和LightSwitch的绝对新手。 此应用程序应该用完浏览器。
我假设你正在尝试从客户端应用程序执行此操作。 如果是这种情况,那么这是不可能的。 LightSwitch基于Silverlight 4,不支持调用本机代码。 它只支持通过COM Automation的调用本地代码,使用通过AutomationFactory类。 看到了
链接地址: http://www.djcxy.com/p/73423.html上一篇: How to access native dll in lightswitch application
下一篇: Problem in saving image to database from picturebox. VB.Net 2008. Framework 3.5