Error integrating MATLAB and Visual Basic
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
The program is simple, it just adds the two number. Here's my matlab function that I created
function out = addMe(a,b)
out = a+b;
end
I then use the NE builder toolbox to generate a .NET component
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/155745/image.jpeg)
Then I'm trying to call the addMe function in Visual Basic. Here's the code:
Imports Add
Public Class Form1
Dim a As Integer = 5
Dim b As Integer = 10
Dim res
Dim addme As New AddClass
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
res = addme.addMe(a, b)
TextBox1.Text = res
End Sub
End Class
But when I run the program, I'm getting this error:
System.InvalidOperationException was unhandled
HResult=-2146233079
Message=An error occurred creating the form. See Exception.InnerException for details. The error is: Could not load type 'Add.AddClass' from assembly 'Add, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.
Source=Add
StackTrace:
at Add.My.MyProject.MyForms.Create__Instance__[T](T Instance) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 190
at Add.My.MyProject.MyForms.get_Form1()
at Add.My.MyApplication.OnCreateMainForm() in c:\users\elvin gentiles\documents\visual studio 2013\Projects\Add\Add\My Project\Application.Designer.vb:line 35
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
at Add.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException: System.TypeLoadException
HResult=-2146233054
Message=Could not load type 'Add.AddClass' from assembly 'Add, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.
Source=Add
TypeName=Add.AddClass
StackTrace:
at Add.Form1..ctor()
InnerException:
0 Kommentare
Antworten (0)
Siehe auch
Kategorien
Mehr zu Write COM Applications to Work with MATLAB finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!