VB error in code

VB error in code

KenVaessen
Enthusiast Enthusiast
687 Views
4 Replies
Message 1 of 5

VB error in code

KenVaessen
Enthusiast
Enthusiast

Hello,

 

I've got the next error in VB

 

\Forms\03_Tools\Frm2dPublish.vb(48,5): warning BC42105: Function 'AssemblyResolve' doesn't return a value on all code paths. A null reference exception could occur at run time when the result is used.

1>vbc : warning BC40059: A reference was created to embedded interop assembly 'Autodesk.Inventor.Interop, Version=26.0.0.0, Culture=neutral, PublicKeyToken=d*************' because of an indirect reference to that assembly from assembly 'MCTY, Version=1.0.0.1, Culture=neutral, PublicKeyToken=null'. Consider changing the 'Embed Interop Types' property on either assembly.

 

 

It refers to the next code Frm2dPublish

 

#Region "START PROGRAM"

 

 

 

    Private Function AssemblyResolve(ByVal sender As Object, ByVal e As ResolveEventArgs) As Assembly

        Dim result As System.Reflection.Assembly = Nothing

 

        If e.Name.ToLower().Contains("grid") = True Then

 

            result = System.Reflection.Assembly.Load(e.Name)

 

 

            Return result

        End If

    End Function

 

    Public Sub New()

 

 

        AddHandler AppDomain.CurrentDomain.AssemblyResolve, AddressOf AssemblyResolve

        ' This call is required by the designer.

        InitializeComponent()

 

        _InventorApplication = StandardAddInServer.InventorApplication

 

        _InventorApplication.SilentOperation = True

 

    End Sub

0 Likes
Accepted solutions (2)
688 Views
4 Replies
Replies (4)
Message 2 of 5

Ralf_Krieg
Advisor
Advisor

Hello

 

Can you try it this way?

Private Function AssemblyResolve(ByVal sender As Object, ByVal e As ResolveEventArgs) As Assembly
    Dim result As System.Reflection.Assembly = Nothing
    If e.Name.ToLower().Contains("grid") = True Then
        result = System.Reflection.Assembly.Load(e.Name)
    End If
    Return result
End Function

 

 

or alternativ

Private Function AssemblyResolve(ByVal sender As Object, ByVal e As ResolveEventArgs) As Assembly
    If e.Name.ToLower().Contains("grid") = True Then
        AssemblyResolve = System.Reflection.Assembly.Load(e.Name)
    End If
End Function

R. Krieg
RKW Solutions
www.rkw-solutions.com
0 Likes
Message 3 of 5

KenVaessen
Enthusiast
Enthusiast

I've deleted the first part so the problem is solved. I've got another error. Can anybody help me with this one?

 

1>------ Rebuild All started: Project: M*****_AddIn, Configuration: Debug Any CPU ------
1>vbc : warning BC40059: A reference was created to embedded interop assembly 'Autodesk.Inventor.Interop, Version=26.0.0.0, Culture=neutral, PublicKeyToken=d*********' because of an indirect reference to that assembly from assembly 'M****, Version=1.0.0.1, Culture=neutral, PublicKeyToken=null'. Consider changing the 'Embed Interop Types' property on either assembly.
1> M*******_AddIn -> F:\*********.dll
1> Microsoft (R) Manifest Tool
1>
1> Copyright (c) Microsoft Corporation.
1>
1> All rights reserved.
1>
========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========

0 Likes
Message 4 of 5

Ralf_Krieg
Advisor
Advisor
Accepted solution

Hello

 

Visual Studio has created a reference to the Autodesk.Inventor.Interop.dll in your current project. That's because the assembly "MCTY" you also have a reference to in your current project, has a reference to this Autodesk.Inventor.Interop.dll.

Go to your project properties, select the tab references and double click the Autodeks.Interop.dll. Now you should see the reference properties. Set "Embed Interop types" to true and compile again.


R. Krieg
RKW Solutions
www.rkw-solutions.com
Message 5 of 5

KenVaessen
Enthusiast
Enthusiast
Accepted solution

KenVaessen_0-1619790183563.png

The interop was filled in false. Adjust this and works ok!

0 Likes