This project is read-only.

Creating a new object from .NET framework

Jan 19, 2009 at 7:35 PM
Hi Leppie,

I am trying to create a new XmlTextReader object like this:

(import
  (rnrs)
  (ironscheme clr))

(clr-using system.xml)

(define xml-text-reader (clr-new xmltextreader "sample.xml"))

and get an error:
C:\Users\XXX\Documents\scheme>"\Program Files\IronScheme\IronScheme.Console.ex
e" HelloWorld.ss
&who:               "clr-new"
&message:           "type not found"
&syntax:            "xmltextreader"

What is a good way to create a .NET object from IronScheme?
Thanks.

Jan 19, 2009 at 7:54 PM
----- Original Message -----
From: [email removed]
To: [email removed]
Sent: Monday, January 19, 2009 9:35 PM
Subject: Creating a new object from .NET framework [IronScheme:44600]

From: ntrifunovic

Hi Leppie,
Hi


I am trying to create a new XmlTextReader object like this:

(import
(rnrs)
(ironscheme clr))

(clr-using system.xml)

It will only look in the currently loaded assemblies in the AppDomain. To force load an assembly, use clr-reference. eg

(clr-reference something.dll) ; this could fail

or

(clr-reference "Fully.Qualified.AssemblyName, etc, etc")

This should work :) (I suggest using the FQ approach for GAC assemblies)

(define xml-text-reader (clr-new xmltextreader "sample.xml"))

Note: I might start enforcing case sensitivity on the clr-XXX forms.



and get an error:
C:\Users\XXX\Documents\scheme>"\Program Files\IronScheme\IronScheme.Console.ex
e" HelloWorld.ss
&who: "clr-new"
&message: "type not found"
&syntax: "xmltextreader"

What is a good way to create a .NET object from IronScheme?
Thanks.

That's the correct way, else you can do it via adding a builtin function or so. I just finished up the ability to pinvoke for IronScheme :)

Cheers

leppie

Jan 20, 2009 at 9:23 PM
I am probably stupid, but just can't load System.Xml.

(clr-reference "System.Xml,Version=2.0.0000.0,Culture=en,PublicKeyToken=b77a5c561934e089")

returns error that can't find the file.
Jan 21, 2009 at 11:54 PM
Edited Jan 21, 2009 at 11:55 PM
Another question: How to use clr-prop-get?

For instance, I managed to set a symbol "assembly" to point to the Assembly object I want, but then how do I execute an equivalent of:

            string name = assembly.FullName;

Thanks.
Jan 22, 2009 at 2:44 AM
From: ntrifunovic
Another question: How to use clr-prop-get?

For instance, I managed to get set a symbol "assembly" to point to the Assembly object I want, but then how do I execute an equivalent of:

string name = assembly.FullName;

Thanks.

(clr-prop-get
Assembly ; type name
FullName ; property name
assembly) ; instance
clr-prop-get (and many of the others) is just a macro of clr-call.
Cheers :)

Jan 22, 2009 at 9:21 PM
Thanks, works :)
 
BTW, I am writing an article about my experiences with IronScheme - if you are interested in taking a look before I publish it to CP, let me know.
Jan 23, 2009 at 4:55 AM
From: ntrifunovic
Thanks, works :)

BTW, I am writing an article about my experiences with IronScheme - if you are interested in taking a look before I publish it to CP, let me know.
That be great thanks!
Just email it to me directly :)
BTW: Beta 2 will be released probably this weekend, as I have been planning to do it for a while, but time has caught up on me. I just need to finish the FFI layer :) This will give people an easier install process for the latest version.
Cheers
leppie