Win32ole access violation
-
I am having problems with win32ole, using Sketchup 2014, 2015
I get the following error message:Error: (in OLE method
AddMyValues': ) OLE error code:80004003 in mscorlib Es wurde versucht, im geschützten Speicher zu lesen oder zu schreiben. Dies ist häufig ein Hinweis darauf, dass anderer Speicher beschädigt ist. HRESULT error code:0x80020009 Exception occurred. C:/Users/Christiansen/AppData/Roaming/SketchUp/SketchUp 2014/SketchUp/Plugins/sci_noise3donline/sci_menu_methods.rb:791:in
method_missing'Ruby Code:
` require 'sci_noise3donline/Desktop/win32ole.so' if Sketchup.version.to_f <14
require 'win32ole' if Sketchup.version.to_f >13lib = WIN32OLE.new('ClassLibrary1.MyFunctions')
tt=lib.AddMyValues()
puts tt`VB.net code: for ClassLibrary1.dll
[pre:1774dfzw]Imports System.Windows.Forms
Public Class MyFunctions
Public Function AddMyValues()
Dim Result As Double
Result = 20
MessageBox.Show(Result)
Return Result
End Function
End Class[/pre:1774dfzw]ClassLibrary1.dll is registered and visible
it is working in Sketchup 2013 even with MessageBox.Show(Result)
and it is working in Sketchup 2014, 2015 when I eliminate MessageBox.Show(Result)Any ideas?
Your help is very much appreciated
-
First idea, use the Ruby API
UI.messagebox()
method, not the one in VB.caption = " Result" UI.messagebox( "\n The result is: #{tt}", MB_MULTILINE, caption )
-
Thanks for the reply.
The messagebox was just a simple example. What I want is to use some complex vb.net forms, which do already exist as a frontend for a calculation System.
I can invoke all functions in this calculation System using win32ole, but just not those showing forms and messageboxes. It does work with Sketchup 2013, where I can use a win23ole.so , located in my plugins folder. But with Sketchup 2014/2015 I have to use the win23ole.so shipped with Sketchup. I have no clue how to solve this Problem.
Help is very much appreciated. -
Have you tried this is a standalone version of Ruby? Just for comparison?
-
I think you need to use another thread for the WinForm windows, e.g MessageBox. I checked the following code. It works. It actually makes more sense to let the WinForm window in a separate thread other than the Sketchup's thread.
Imports System.Windows.Forms Public Class MyFunctions Private Sub showMessage(ByVal msg As String) MessageBox.Show(msg) End Sub Public Function AddMyValues() Dim Result As Double Result = 20 Dim t1 As New Threading.Thread(AddressOf showMessage) t1.Start(Result) Return Result End Function End Class
Advertisement