SideBySide: X# DLL to use in VO

This forum is meant for questions and discussions about the X# language and tools
Post Reply
ic2
Posts: 1865
Joined: Sun Feb 28, 2016 11:30 pm
Location: Holland

SideBySide: X# DLL to use in VO

Post by ic2 »

We want to replace our Vulcan DLL with a X# DLL, which means that we we have to go through the whole process again. This is how Vulcan program starts:

BEGIN NAMESPACE IC2VulcanMethods
[ClassInterface(ClassInterfaceType.AutoDual)];
[Guid("487BF093-A8F9-4119-82EB-414A78FCF342")] ;
[ComVisibleAttribute( TRUE )];
CLASS VoVulcanClass

When I do the same (with a freshly generated GUID) in the X# DLL, I get the following error:

Error XS9002 Parser: unexpected input 'CRLF', are you missing a closing ')' or '}' ? IC2ExtLibForVO D:XSharpProjectsIC2ExtLibForVOIC2ExtLibForVO_StartData.prg 26

What should I change in X# to get this working?

Dick

PS: I saw I just posted subject 100. Does this entitle me for a price?
User avatar
wriedmann
Posts: 3784
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

SideBySide: X# DLL to use in VO

Post by wriedmann »

Hi Dick,

this is code from my own (working) COM-Component:

Code: Select all

[ComVisible(true)];
[Guid("EFCF1B80-9602-4282-A7F9-4CD3384484D4")];
[ClassInterface(ClassInterfaceType.None)];
[ProgId("EPPLusComponent.XlsxFile")];
public class XlsxFile implements IXlsxFile
and I need a

Code: Select all

using System.Runtime.InteropServices
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
User avatar
Chris
Posts: 4992
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

SideBySide: X# DLL to use in VO

Post by Chris »

Hi Dick,

The code as you posted it here is fine, it will not give any parser error messages. I suspect when you got this error, you had omitted one of the ";"s at the end of on of the attribute lines. Try a rebuild now, does the error go away? If not, at which line and col does it point?

btw, that was post #100 in the specific subcategory only. Maybe we can do something for subject #1000 overall (we're at 388 now) or at post #10,000 (2,693 now) :-)

Chris
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
ic2
Posts: 1865
Joined: Sun Feb 28, 2016 11:30 pm
Location: Holland

SideBySide: X# DLL to use in VO

Post by ic2 »

Hello Chris, Wolfgang.

I knew it was only the 100th posting here ;)

I found the problem. It was an empty line between the code and the class. Removed it and it compiles. I will now try to finalize this (checking Wolfgangs remarks as well, I did not use the ProgId so far) and write a short summary if it works.

Dick
ic2
Posts: 1865
Joined: Sun Feb 28, 2016 11:30 pm
Location: Holland

SideBySide: X# DLL to use in VO

Post by ic2 »

After the usual problems I got it working, this is what you have to do to call methods in a X# DLL (in my case it is C# and X# code) from VO without the need to Regasm the DLL"

What I did is this:
1 In the properties of the project, Build Events, Post-build I added this (first without the rem) (you may have to change the path to mt.exe):

rem "C:Program Files (x86)Windows Kits10binx64mt.exe" -managedassemblyname:$(TargetFileName) -nodependency -out:$(ProjectDir)$(ProjectName).manifest
"C:Program Files (x86)Windows Kits10binx64mt.exe" -manifest "$(ProjectDir)$(ProjectName).manifest" -outputresource:"$(TargetFileName)";2
Copy "$(TargetDir)*.dll" "c:somewhere"

2 In the VO Manifest file, included in the exe, I started with the Appwizcctl6.man file, changed the program name and inserted

<dependency>
<dependentAssembly>
<assemblyIdentity name="IC2ExtLibForVO" version="1.0.65534.65534" processorArchitecture="msil"></assemblyIdentity>
</dependentAssembly>
</dependency>

Note that for the Vulcan DLL I wrote a few years ago I had to use processorArchitecture="*". For X# the program won't start, in the application log you'll find this error:

Activation context generation failed for "d:XSharpVOTestXSharpVOTest.DBG".Error in manifest or policy file "d:XSharpVOTestIC2ExtLibForVO.DLL" on line 1. Component identity found in manifest does not match the identity of the component requested. Reference is IC2ExtLibForVO,processorArchitecture="x86",version="1.0.65534.65534". Definition is IC2ExtLibForVO,processorArchitecture="msil",version="1.0.65534.65534". Please use sxstrace.exe for detailed diagnosis.

Apparently the DLL is supposed to be based on 'msil' (while I would say it's x86, see earlier discussions in this forum) - msil is introduced in VS 2015 and makes the OS chosoe between 32 and 64 bits I read.

3 I copied the DLL's generated (recompiled hem with REM in the first line which I remember was something which needed to be done for some reason) and then I could start the VO exe, and run methods from the DLL.

When I have this 100% ready I'll make a full descriptions for Examples.

Dick
User avatar
robert
Posts: 4568
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

SideBySide: X# DLL to use in VO

Post by robert »

Dick,
One of the problem in your message has to do with automatic version number generating:
you are using the syntax to automatically generate a version number for your assembly

Code: Select all

[assembly: AssemblyVersion("1.0.*")]
This will automatically generate the 3rd and 4th part of the version number.
Each time you recompile the version number will change !
For an assembly that implements a COM interface that is usually not a good idea. You may want to control the complete version number in your code.

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
Post Reply