我有枚举错误的枚举 我正在使用Visual Studio 2013,我正在尝试编写VB脚本任务。
我的代码应该复制在excel中的模板上,(表2)并使用我要在4loop中传递的变量重命名它 我收到了这个编译错误。“类'ScriptMain'中的枚举'ScriptResults'和枚举'ScriptResults'冲突”
我知道错误存在于我的第二个Enum ScriptResults中,并且我不应该有两个但是当我把一个脚本结果带走时我会在整个地方得到这个错误“当它的引用时,不允许引用类'ApplicationClass'程序集使用No-PIA模式链接。“
这是我的所有代码,有什么建议吗?
class Window(QtGui.QMainWindow):
#Window Settings
def __init__(self):
...
#Font Family Input
#Settings Menubar
settings = menubar.addMenu('&Settings')
menu_font = settings.addMenu("&Font")
font_family = QtGui.QWidgetAction(self)
font_family.setDefaultWidget(fontBox)
menu_font.addAction(font_family)
font_size = QtGui.QWidgetAction(self)
font_size.setDefaultWidget(fontSize)
menu_size = settings.addMenu("&Font Size")
menu_size.addAction(font_size)
self.toolbar()
...
结束班
答案 0 :(得分:0)
我回答了我自己的问题,我所做的是取出最初的枚举脚本结果,然后替换所有内容,使它们不再是一个类,所以类错误就会消失。它工作!
Imports System
Imports System.Data
Imports System.Math
Imports Microsoft.SqlServer.Dts.Runtime
Imports Microsoft.Office.Interop
<System.CLSCompliantAttribute(False)> _
Partial Public Class ScriptMain
Inherits
Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
Public Sub Main()
Dim Excel As Excel.Application = Nothing
Dim Book As Excel.Workbook = Nothing
Dim Books As Excel.Workbooks = Nothing
Dim sFilePath As String = CStr(Dts.Variables("User::CopyClaimsSubmission").Value)
Dim excelWorkSheet As Excel.Worksheet
Try
'Start Excel and open the workbook.
Excel = CreateObject("Excel.Application")
Excel.Visible = False
Books = Excel.Workbooks
Book = Books.Open(sFilePath)
If Book.Sheets.Count > 0 Then
'copy first worksheet
Excel.ActiveWorkbook.Sheets(2).Copy(Type.Missing, Excel.ActiveWorkbook.Sheets(2))
'select the copy
excelWorkSheet = Excel.ActiveWorkbook.Sheets(3)
'test: show the new name
'MsgBox(excelWorkSheet.Name.ToString +" rename to " CStr(Dts.Variables("User::Iterator_Item").Value))
'rename the sheet
excelWorkSheet.Name = CStr(Dts.Variables("User::forloopenumorator").Value)
End If
'Clean-up: Close the workbook and quit Excel.
Book.Save()
Excel.Quit()
Dts.TaskResult = ScriptResults.Success
Finally
If Book IsNot Nothing Then System.Runtime.InteropServices.Marshal.ReleaseComObject(Book)
If Books IsNot Nothing Then System.Runtime.InteropServices.Marshal.ReleaseComObject(Books)
If Excel IsNot Nothing Then System.Runtime.InteropServices.Marshal.ReleaseComObject(Excel)
Book = Nothing
Books = Nothing
Excel = Nothing
End Try
End Sub
Enum ScriptResults
Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success
Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
End Enum
结束班