Calling dotnet classes (OpenInsight 32-bit Specific)
At 06 DEC 2010 05:43:34PM James wrote:
Hi all
I'm running OI 9.2 on WinXP and can call my own dotNet assembly but had a problem when it moved to a 64bit OS. So I went back and tried to call a function which returns a String from the System 2.0 assembly as per below.
I'm trying to call the GetHostName method and get back 'No method found that matches this request' however I can see the method when I get a do a send_message.net(hwnd_class, 'GetHostName',
, 'System.String') Any ideas appreciated! Thanks, James <code> $insert [/color]logical [/color]$insert [/color]REVDOTNETEQUATES; valid=true$; [/color] hwnd_dotnet=StartDotNet(); dotnet2_system_fullpath=CheckDotNet([/color]'2.0'[/color]):[/color]'\System.dll' [/color];[/color]*=c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.dll [/color]x=set_property.net(hwnd_dotnet, [/color]'AssemblyName'[/color], dotnet2_system_fullpath); hwnd_class=create_class.net(hwnd_dotnet, [/color]'System.Net.Dns'[/color], [/color]0[/color]); [/color]gosub [/color]check_for_error; [/color] [/color]if [/color]valid [/color]then [/color] debugging only - does method exist? [/color]mthd=get_info.net(hwnd_class, REVDOTNET_INFO_METHODS, [/color]'GetHostName'[/color]) [/color]gosub [/color]check_for_error; [/color]if [/color]valid [/color]and [/color]mthd != [/color]
[/color]then [/color]retval=send_message.net(hwnd_class, [/color]'GetHostName'[/color], [/color]
[/color], [/color]'System.String'[/color]) [/color]gosub [/color]check_for_error; [/color]end [/color] release memory [/color]Free_class.net(hwnd_class) [/color]end [/color] return [/color] [/color]check_for_error: [/color]if [/color]get_status(oErrorDetails) [/color]then [/color]debug [/color]valid=false$; [/color]end return[/color][/color][/size] </code> </QUOTE> —- === At 06 DEC 2010 06:45PM Barry Stevens wrote: === <QUOTE>]] !=Wot The!
At 06 DEC 2010 07:45PM James Birnie wrote:
Hi Barry
Syntax is valid :)
I haven't written OI in a while and am having a couple of memory issues tho e.g. unecessary semi-colons at end of *some* lines…
At 07 DEC 2010 12:17PM Barry Stevens wrote:
so what does != expand to , still just=?
At 07 DEC 2010 12:33PM Barry Stevens wrote:
Where in MSDN do you find all the DOTNETs available and what they do.
Also I looked in the "c:\WINDOWS\Microsoft.NET\Framework\" and see that there are other folders with 'Versions' greater than v2.0.50727, so if you have hard coded the v# , how would you access an updated version. (maybe they are 64bit)
I notice the DOTNETEXPLORER doesnt like the later versions.
I am a *virgin* to DOTNET , as you can guess, I still use olecreateinstance call to ms ole .application (even struggle with that, but there are a lot of examples in the forum (thanks to bob).
There should be more examples published for DOTNET and put in the knowledge base, even if links to google docs that have been created.
This should even be done now with the google docs that bob has already done, at the moment the links are hidden in forum responses.
Anyway enough of my babble. Any help, tips, links you can provide would be good.
PS: Actually, what I was looking for is if there is a DOTNET version of ms ole 'outlook.application', I am worried about it not workinging fully in outlook 2010.
tia
At 07 DEC 2010 01:32PM Bryan Shumsky wrote:
Hi, James. Glad to see you're using RevDotNet with (some) success.
I coded in your routine, and found that the problem is in the send_message.net call:
] retval=send_message.net(hwnd_class, "GetHostName", "", "System.String")
This is telling .net to call GetHostName with a System.String parameter that is null. However, if you look at the GetHostName method, although the _return_ value is a System.String, the method itself has NO parameters. These two (a null String, versus no parameter at all) are not interchangeable; .net looks for a method with the 'signature' you have provided, and can't find one, which is why the call fails.
However, if you change your call to this:
] retval=send_message.net(hwnd_class, "GetHostName")
I believe you'll find it works properly (at least, it does for me).
Hope that helps!
- Bryan Shumsky
Revelation Software
At 07 DEC 2010 02:25PM Bob Carten wrote:
Use
retval=send_message.net(hwnd_class, 'GetHostName')
instead of
retval=send_message.net(hwnd_class, 'GetHostName',
, 'System.String') That worked for me. The issue is the lookup logic in the revdotnet bridge. .Net can have several functions with the same name but different parameters. Revdotnet find the one with the same name and numeber/type of parameters. It looked for a method that took a string, could not find one. When I passed in nothing, instead of
, 'SYSTEM.String' revdotnet found the method that does not take an parameters.To see more of how revdotnet interacts with dotnet , EXEC REVDOTNETEXPLORER from TCL, use it to browse .Net Classes.
At 07 DEC 2010 02:28PM Barry Stevens wrote:
Actually, you have helped me already with your subjet.
I was just googling .net ; now if I use .net class library I get results.
BUT i cant 'decode' any of the examples to OI.
C# examples look the closest.
Still interested in yor references and OI examples.
I am going to post an outlook c# example in the works forum.
At 07 DEC 2010 03:46PM Bryan Shumsky wrote:
Hey! I had just said that!
![]()
At 07 DEC 2010 04:37PM [url=http://www.sprezzatura.com]The Sprezzatura Group[/url] wrote:
Not equals - see http://sharpertutorials.com/c-operator-list/
Poke around you might find more undocumented operators to assist those who switch backwards and forwards between development languages ;).
World leaders in all things RevSoft
At 07 DEC 2010 04:55PM [url=http://www.sprezzatura.com]The Sprezzatura Group[/url] wrote:
That'd just be DOTNETEXPLORER ;)
World leaders in all things RevSoft
At 07 DEC 2010 04:55PM James Birnie wrote:
Hi Bryan
That did it, thanks for the tip. Getting direct access to these library and custom assemblies is a very powerful feature - thanks a lot!
Cheers,
James
At 07 DEC 2010 04:58PM James Birnie wrote:
Thanks Bob!
At 07 DEC 2010 05:14PM James Birnie wrote:
Hi Barry
Reading through the entire list of assemblies would take a while :) You'd be better of working out what exactly what you want to do + then creating your own C# assemblies (called a "class library" within visual studio) which wraps and/or expands the functionality, that you can call simply from OI.
You'll soon notice that almost anything you want to do will be possible in C# + its a relatively easy language to use + there are heaps of resources e.g. http://www.codeproject.com/info/search.aspx
p.s. any assembly you create will need to have a "strong name" (using sn.exe) to be referenced from OI, however you don't need to register them in the GAC e.g. they could be in a single shared directory that you reference from OI.
At 07 DEC 2010 09:47PM Barry Stevens wrote:
]….then creating your own C# assemblies
, thanks for your help but *I don't think so*…too old for that.
At 07 DEC 2010 09:50PM Barry Stevens wrote:
Cool, thanks.
Probably wont use, look at my code 6 months later and think UHHH
At 07 DEC 2010 09:52PM Barry Stevens wrote:
I knew that
At 13 DEC 2010 10:06AM Jared Bratu wrote:
You can use a single shared directory to store controls but be careful if the directory is on a network. .Net controls have additional layers of security. You'll need to use caspol to adjust the Framework security levels.
The OpenInsight ClientSetup.exe has the same issue. Instead of storing the .Net components inside the OpenInsight directory a design choice was made to install the libraries locally on each workstation to minimize complications of changing the .Net security model.