|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
ikvmc referencesHi All,
Hi Jeroen, I would like to use static ikvmc compilation in the following scenario: I have a client application written in C# (.Net) and a server application in Java. Now I would like to use a small and well known number of classes (which I will call BusinessObjects), in both, client (.Net) and server (Java) applications. So I got the idea to have ikvmc.exe create a .net dll from the jar file containing the BusinessObjects classes. Typically the BusinessObjects.jar file contains functioality commonly used on the server as well as on the client, like, in my case, the proprties containing the data, some validation rule checking, and some simple basic business logic. For this functionality ikvmc would be ideally suited to create a .Net dll from a .jar file as it doesn't rely on a huge amount of framework code or base classes. Still the BusinessObjects classes will rely on some kind of base functionality when implementing actions common to all BusinessObjects like loading, saving etc. Obviously that functionality will be implemented totally different on the server compared to the client. So I had the idea to implement different two different sets of base classes, one in C# (.Net) and on in Java that can be used as base classes for the BusinessObjects in the respective environment (server or client). Both sets of base classes are identical in the methods they provide and the method signatures but differ in the implementation. When trying to set up such a test scenario I encountered the following problem. My first naive try was to create two Java libraries (.jar) files: BOBase.jar contains the class BOBase.Base BusinessObjects.jar contains the class BusinessObjects.Customer extends BOBase.Base In addition I created the following .net assembly written in C#: BOBaseNet.dll contains the class BOBase.Base Both BOBase.Base classes, the one in Java as well as the one in C# have the same methods and the methods have identical signatures. When trying to ikvmc BusinessObjects.jar, I get the following result: Note IKVMC0002: output file is "BusinessObjects.dll" Warning IKVMC0105: unable to compile class "BusinessObjects.Customer" (missing class "BOBase.Base") which is clear, as the base class is not part of the BusinessObject.jar file (by intention). So I thought that specifying the option "-reference:BOBaseNet.dll" in the call to ikvmc.exe, this reference could be resolved. Unfortunately it wasn't. Ikvmc still reports the exact error as shown above, even with a reference to BOBaseNet.dll specified. I triple-checked with Reflector that the BoBaseNet.dll contains the required base class (BOBase.Base) and that all identifiers, class names and namespaces are spelled correctly. So please, could you explain to me why ikvmc does not accept this reference? While toying around, I found a way how to accomplish my scenario, but it seems a bit awkward to me. Nevertheless it might help other people if it turns out that this is the only solution, or it might be of some help in trying to find out why my first approach doesn't work. Here's how it worked: From BOBaseNet.dll which is the assembly written in C#, I created a stub jar file using ikvmstub.exe. The name of this file is BOBaseNet.jar. Using the IKVM.Attributes.NoPackagePrefixAttribute allowed me to get rid of the annoying cli. outer namespace prefix. In the BusinessObject Java project, I referenced BOBaseNet.jar instead of BOBase.jar to build the BusinessObject.jar library. In the Server java application, I was able to use the BusinessObject classes productively by referencing the original java BOBase.jar library instead of the generated stub jar file. But using this approach ikvmc will actually compile BusinessObject.jar into BusinessObject.dll when referencing the hand-written C# Dll BoBaseNet.jar. Thanks for any explanation why the latter works while the first approach does not. |
|
|
Re: ikvmc referencesHi,
The key is the NoPackagePrefixAttribute. By default any .NET type will always have the cli namespace prefix, so in your first attempt the BOBase.Base was actually seen as cli.BOBase.Base by ikvmc. Whether you reference BoBaseNet.jar or BoBase.jar in your Java project makes no difference (if they both expose the same types/members). Regards, Jeroen > -----Original Message----- > From: zehmueller [mailto:chrism@...] > Sent: Thursday, September 10, 2009 3:07 PM > To: ikvm-developers@... > Subject: [Ikvm-developers] ikvmc references > > > Hi All, > Hi Jeroen, > I would like to use static ikvmc compilation in the following scenario: > I have a client application written in C# (.Net) and a server > application in Java. Now I would like to use a small and well known > number of classes (which I will call BusinessObjects), in both, client > (.Net) and server > (Java) applications. So I got the idea to have ikvmc.exe create a .net > dll from the jar file containing the BusinessObjects classes. > > Typically the BusinessObjects.jar file contains functioality commonly > used on the server as well as on the client, like, in my case, the > proprties containing the data, some validation rule checking, and some > simple basic business logic. For this functionality ikvmc would be > ideally suited to create a .Net dll from a .jar file as it doesn't rely > on a huge amount of framework code or base classes. > > Still the BusinessObjects classes will rely on some kind of base > functionality when implementing actions common to all BusinessObjects > like loading, saving etc. Obviously that functionality will be > implemented totally different on the server compared to the client. > > So I had the idea to implement different two different sets of base > classes, one in C# (.Net) and on in Java that can be used as base > classes for the BusinessObjects in the respective environment (server > or client). Both sets of base classes are identical in the methods they > provide and the method signatures but differ in the implementation. > > When trying to set up such a test scenario I encountered the following > problem. > > My first naive try was to create two Java libraries (.jar) files: > BOBase.jar contains the class > BOBase.Base > > BusinessObjects.jar contains the class > BusinessObjects.Customer extends BOBase.Base > > In addition I created the following .net assembly written in C#: > BOBaseNet.dll contains the class > BOBase.Base > > Both BOBase.Base classes, the one in Java as well as the one in C# have > the same methods and the methods have identical signatures. > > When trying to ikvmc BusinessObjects.jar, I get the following result: > > Note IKVMC0002: output file is "BusinessObjects.dll" > Warning IKVMC0105: unable to compile class "BusinessObjects.Customer" > (missing class "BOBase.Base") > > which is clear, as the base class is not part of the BusinessObject.jar > file (by intention). So I thought that specifying the option "- > reference:BOBaseNet.dll" in the call to ikvmc.exe, this reference could > be resolved. > Unfortunately it wasn't. Ikvmc still reports the exact error as shown > above, even with a reference to BOBaseNet.dll specified. I triple- > checked with Reflector that the BoBaseNet.dll contains the required > base class > (BOBase.Base) and that all identifiers, class names and namespaces are > spelled correctly. > > So please, could you explain to me why ikvmc does not accept this > reference? > > While toying around, I found a way how to accomplish my scenario, but > it seems a bit awkward to me. Nevertheless it might help other people > if it turns out that this is the only solution, or it might be of some > help in trying to find out why my first approach doesn't work. Here's > how it worked: > > >From BOBaseNet.dll which is the assembly written in C#, I created a > >stub jar > file using ikvmstub.exe. The name of this file is BOBaseNet.jar. Using > the IKVM.Attributes.NoPackagePrefixAttribute allowed me to get rid of > the annoying cli. outer namespace prefix. > In the BusinessObject Java project, I referenced BOBaseNet.jar instead > of BOBase.jar to build the BusinessObject.jar library. > In the Server java application, I was able to use the BusinessObject > classes productively by referencing the original java BOBase.jar > library instead of the generated stub jar file. > But using this approach ikvmc will actually compile BusinessObject.jar > into BusinessObject.dll when referencing the hand-written C# Dll > BoBaseNet.jar. > > Thanks for any explanation why the latter works while the first > approach does not. > > > -- > View this message in context: http://www.nabble.com/ikvmc-references- > tp25382803p25382803.html > Sent from the IKVM .NET - Dev mailing list archive at Nabble.com. > > > ----------------------------------------------------------------------- > ------- > Let Crystal Reports handle the reporting - Free Crystal Reports 2008 > 30-Day > trial. Simplify your report design, integration and deployment - and > focus on > what you do best, core application coding. Discover what's new with > Crystal Reports now. http://p.sf.net/sfu/bobj-july > _______________________________________________ > Ikvm-developers mailing list > Ikvm-developers@... > https://lists.sourceforge.net/lists/listinfo/ikvm-developers ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Ikvm-developers mailing list Ikvm-developers@... https://lists.sourceforge.net/lists/listinfo/ikvm-developers |
|
|
|
| Free embeddable forum powered by Nabble | Forum Help |