簡體   English   中英

部署Outlook加載項-沒有資源/圖像

[英]Deployment of Outlook Add-in - no resources / images

我正在嘗試部署我編寫的一個加載項,但是它找不到關聯的資源-即功能區的圖像。

我的GetImage函數是這樣的:

    Dim path As String = AppDomain.CurrentDomain.BaseDirectory
    System.Windows.Forms.MessageBox.Show(path)
    path = path.Substring(0, path.LastIndexOf("\bin")) + "\Resources\" + imageName
    Return New Drawing.Bitmap(path)

它失敗的原因似乎是AppDomain.CurrentDomain.BaseDirectory是C:\\Users\\MZE\\AppData\\Local\\Apps\\2.0\\4RZKJG5Q.XVT\\72NBJ1XY.1QH\\andsoon 因此,出於某種原因,圖像不會作為資源推出。 我通過Visual Studio中的項目屬性添加資源對話框添加了它們。 我還嘗試過將構建設置為資源,然后將其復制到Visual Studio的圖像屬性中。

我將不勝感激。

確保添加到項目中的圖像在解決方案的“資源”部分中。

資源菜單

檢查圖像的項目文件夾結構。

項目樹

為您的GetImage函數嘗試以下修訂的過程。 使用IntelliSense導航到My.Resources.``resourceName 您不需要引用圖像的路徑。

Public Function GetImage(control As Office.IRibbonControl) As System.Drawing.Bitmap
    Try
        Select Case control.Id
            Case "btnYourButton1"
                Return My.Resources.Image1
            Case "btnYourButton2"
                Return My.Resources.Image2
            Case "btnYourButton3"
                Return My.Resources.Image3
            Case Else
                Return Nothing

        End Select

    Catch ex As Exception
        Return Nothing

    End Try

End Function

這是Resources對象的Microsoft參考

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM