Forums

using a dll

General discussion about Cobra. Releases and general news will also be posted here.
Feel free to ask questions or just say "Hello".

using a dll

Postby natter » Fri Nov 14, 2008 8:34 am

today i found http://sourceforge.net/projects/scide/
and downloaded an example sourcecode which uses the included ScintillaNET.dll
i converted that example by hand to cobra code and it says to

use Scintilla from ScintillaNET -> error: Cannot find library file "ScintillaNET"

the dll is located in the same directory as the sourcecode. in addition i put it in the .NET directory

so, how do you use dll files?
can i use any dll or only special .net dlls?



edit:
i just realise the ScintillaNEt project on sourceforge is last updated in 2004 and its now hosted at http://www.scide.net ^^
natter
 
Posts: 20

Re: using a dll

Postby Charles » Fri Nov 14, 2008 1:23 pm

Can you use "Upload attachment" here to provide your sample? Then I can try this out and let you know what I find.
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: using a dll

Postby natter » Fri Nov 14, 2008 2:12 pm

Attachments
main.cobra
(15.73 KiB) Downloaded 427 times
natter
 
Posts: 20

Re: using a dll

Postby Charles » Fri Nov 14, 2008 9:23 pm

Actually, I guess I didn't need your code sample after all. I used Reflector on the DLL and I can see that the namespace is called "ScintillaNet" instead of "Scintilla". So you can just say:

use ScintillaNet

Because the namespace and DLL name match.

I then get some different errors, but I think you can work through those.

You can get Reflector here:
http://www.red-gate.com/products/reflector/

Good luck. Let us know if you produce something interesting for the Cobra community with this.
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: using a dll

Postby natter » Sat Nov 15, 2008 5:20 am

it doesnt work

i also tried to use the 2.0 release from scide.net as the newest requires .Net 3.x

i still would like to know:
-how to use dll files
-if i can use any dll or only special .net dlls
natter
 
Posts: 20

Re: using a dll

Postby Charles » Sat Nov 15, 2008 10:39 am

To use a DLL file, you can say:

cobra -ref:Foo.Bar MyProgram.cobra

If the namespace and the DLL match, you can just say:

cobra MyProgram.cobra

and in your source code have:

use Foo.Bar

I highly recommend using Cobra out of the repository: http://cobra-language.com/source/
After you get a copy, cd into the Source directory and run install-from-workspace. Then cd out to your project directory.

You can use any .NET 2.0 DLL. I haven't tested Cobra with .NET 3.x. You cannot use a native machine code DLL. It has to be .NET.

When you say "it doesnt work", are you getting the same error? Are you using the latest Cobra out of the repository?

"use Scintilla" worked for me.

-Chuck
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: using a dll

Postby natter » Sat Nov 15, 2008 1:07 pm

yes, im using the current svn cobra version.

'use Scintilla' -> error: Cannot find namespace "Scintilla".

'ref:ScintillaNET' -> error: Cannot locate assembly reference "ScintillaNET.dll".
(i guess the dll is placed right if its in the same directory as the cobra file)

...
whatever, i wouldnt use that dll anyway, as its from 2004
the current version requires .NET 3.x which isnt supported by my system (win2k)
natter
 
Posts: 20

Re: using a dll

Postby Charles » Sat Nov 15, 2008 5:04 pm

Not 'use Scintilla'.

use ScintillaNet

The DLL I'm using is:
08/04/2008 03:16 PM 558,080 ScintillaNet.dll

And yes I put it in the same directory as the Cobra file. And for good luck, use the exact same case as the file ("Net" vs. "NET").

HTH,
-Chuck
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: using a dll

Postby natter » Sat Nov 15, 2008 6:27 pm

this is getting weird.
where did you get that dll from?
i got mine from http://sourceforge.net/project/showfile ... p_id=92619
and its called ScintillaNET.dll
its from 2004, yours from 2008
error: Cannot find namespace "ScintillaNET"
...(10 minutes later)...
yours is the current release from http://www.scide.net
its called ScintillaNet.dll
if i download their installer it says .NET 3.x required and quits
anyway, i downloaded the zip, put all files in the project folder
error: Cannot find namespace "ScintillaNet"

i think i tried all combos of ScintillaNET, ScintillaNet, Scintilla, Scintilla* from, -ref, etc..
natter
 
Posts: 20

Re: using a dll

Postby Charles » Sat Nov 15, 2008 6:56 pm

The zip file I downloaded is called:

ScintillaNET 2.0.zip

I grabbed the DLL out of it and put that and your file in a directory.

I changed the top portion of your file to read:
use System
use System.Drawing
use System.Collections
use System.ComponentModel
use System.Windows.Forms
use System.Data
use System.IO
use System.Text
use ScintillaNet

namespace ScNote

class ScNoteMain
inherits Form
...

The only line I changed was:

use ScintillaNet

The command line I use to compile is:

cobra main

I get warnings and errors that need to be addressed, but no complaints about the namespace, .NET 3.0, or anything else.

-Chuck
Charles
 
Posts: 2515
Location: Los Angeles, CA

Next

Return to Discussion

Who is online

Users browsing this forum: No registered users and 9 guests