Version 0.0.0.0 when creating strong named assembly - linux

We're building a C# wrapper for a C library in embedded Linux, and we want to install it into the GAC of the target system.
To do that, I've used sn to create a keypair and mcs to compile the code:
sn -k keypair.snk
mcs /target:library -keyfile:keypair.snk -out:MyLib.dll src/*.cs
Now, once that's built, I use gacutil to inject it into the GAC with:
gacutil /i -gacdir /path/to/gac MyLib.dll
What I end up with is the correct file structure but the version number is set to 0.0.0.0:
.../usr/lib/mono/gac/MyLib
.../usr/lib/mono/gac/MyLib/0.0.0.0__3141592653589fff
.../usr/lib/mono/gac/MyLib/0.0.0.0__3141592653589fff/MyLib.dll
I want the version of the wrapper to match that of the underlying C code being used so my question is (hopefully) a simple one. Where is that current version coming from, and how do I get it to be 3.14.15.9 (for example)?

Add an assembly level attribute called AssemblyVersion to your C# source. This is usually added in a file named AssemblyInfo.cs :
Note: This is a cut/paste of an auto-generated project file, I updated the AssemblyVersion attribute and you only have to include the attributes you want the CIL assembly to contain
using System.Reflection;
//using System.Runtime.CompilerServices;
// Information about this assembly is defined by the following attributes.
// Change them to the values specific to your project.
[assembly: AssemblyTitle("Sushi.Task.Lib")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("SushiHangover")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("SushiHangover - 2016")]
[assembly: AssemblyTrademark("SushiHangover")]
[assembly: AssemblyCulture("")]
// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
// and "{Major}.{Minor}.{Build}.*" will update just the revision.
[assembly: AssemblyVersion("3.14.15.9")]
// The following attributes are used to specify the signing key for the assembly,
// if desired. See the Mono documentation for more information about signing.
//[assembly: AssemblyDelaySign(false)]
//[assembly: AssemblyKeyFile("")]
Add that source file to the others that you are compiling.
Install it:
>gacutil /i Sushi.Task.Lib.dll
And retrieve the details:
>gacutil /l |grep -i sushi
Sushi.Task.Lib, Version=3.14.15.9, Culture=neutral,....
File system:
ls -Rl /Frameworks/Mono.framework/gac | grep -i sushi
drwxr-xr-x 3 root admin 102 Jun 8 20:25 Sushi.Task.Lib
/Frameworks/Mono.framework/gac/Sushi.Task.Lib:
/Frameworks/Mono.framework/gac/Sushi.Task.Lib/3.14.15.9__629e3fd32ae394a7:.....

Related

Veracode through an error - ASPCONFIG: Could not autodiscover 'components.config'

I have a Veracode plugin in my VS 2013 Professional.
I have ucommerce.dll, Sitecore.Kernel and Sitecore.Analytics.dll
I set copy local true for all above dll files.
When i tried to pre-compile all the web project I'm getting a below error message
1>------ Pre-compile started: Project: XXXXX.Web.PQRPorta\ ------
1>Pre-compiling with command similar to the following:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_compiler.exe -p
"C:/XXXXX.Web.PQRPortal" -v "XXXXX.Web.PQRPortal/" -fixednames -f -c
-d "C:/SVN/trunk/Releases/SourceCode/Source/PrecompiledWeb/XXXXX.Web.PQRPortal"
1>error ASPCONFIG: Could not autodiscover 'components.config'. Make
sure it's present in the application folder
'C:\SVN\trunk\Releases\SourceCode\Source\XXXXX.Web.PQRPortal\' or in a
sub folder. Paths ignored
''C:\SVN\trunk\Releases\SourceCode\Source\XXXXX.Web.PQRPortal\bin',
'C:\SVN\trunk\Releases\SourceCode\Source\XXXXX.Web.PQRPortal\App_Data',
'C:\SVN\trunk\Releases\SourceCode\Source\XXXXX.Web.PQRPortal\obj''
1>XXXXX.Web.PQRPortal\ - 1 error, 0 warnings
Is there any configuration missing?
Update
I found the components.config file inside
C:\inetpub\wwwroot\XXXX\Website\sitecore modules\Shell\uCommerce\Configuration
and I added the file inside the web project root directory and tried to precompile web project, now I’m getting different error error
ASPRUNTIME: Type is not resolved for member 'Castle.Windsor.Configuration.Interpreters.ConfigurationProcessingException,Cast‌​le.Windsor, Version=3.2.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc'.
any solution for it?
The components.config is a file uCommerce need.
The configuration file should be placed somewhere below the uCommerce folder. (not sure where depend on the version) It will automatically be picked up when the application starts up.

How to replace text in files using Gradle/Groovy functionality

I am trying to work around the problem described in GRADLE-2293 where generated files are always updated because a timestamp is written to the Eclipse files located in directory .settings by the Gradle plugin which generates the Eclipse project files.
The files contain a header like this which I would like to remove
#
#Fri Mar 27 10:26:55 CET 2015
Currently I am using an Exec task to use the external application sed to cut out lines starting with '#':
task adjustEclipseSettingsFile(type: Exec) {
executable 'sed'
args '-i','-e','s/^#.*//g','.settings/org.eclipse.jdt.core.prefs'
}
eclipseJdt.finalizedBy adjustEclipseSettingsFile
however this adds a dependency on operating system binaries that I would like to avoid.
How can I do this simple removal of lines starting with '#' in a Gradle task without calling external tools?
There are really many ways of doing it, the one with ant is probably most reliable:
task removeLines << {
ant.replaceregexp(match:'^#.*', replace:'', flags:'g', byline:true) {
fileset(dir: project.projectDir, includes: 'lol')
}
}

Unable to load so file from Java in Eclipse On Ubuntu

I have some code that tries to load a C library as follows :-
public ThreadAffinity() {
ctest = (CTest) Native.loadLibrary("ctest", CTest.class);
}
However I get the following error when trying to build the project; The error I get is as follows :-
UnsatisfiedLinkError: Unable to load library 'libctest': liblibctest.so: cannot open shared object file: No such file or directory
at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:166)
at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:239)
at com.sun.jna.Library$Handler.<init>(Library.java:140)
at com.sun.jna.Native.loadLibrary(Native.java:393)
at com.sun.jna.Native.loadLibrary(Native.java:378)
at com.threads.ThreadAffinity.<init>(ThreadAffinity.java:11)
at com.threads.ThreadAffinity.main(ThreadAffinity.java:45)
The current working directory is the root of the project and thats where the so file is located. I also tried modifying the LD_PRELOAD variable to point to my so file; however the error persists.
It works just fine on my OSX where the dylib is located exactly where the so file is currently(project root).
What am I doing wrong?
From the exception:
UnsatisfiedLinkError: Unable to load library 'libctest': liblibctest.so: cannot open shared object file: No such file or directory
It implies you used something like:
public ThreadAffinity() {
ctest = (CTest) Native.loadLibrary("libctest", CTest.class);
}
and not:
public ThreadAffinity() {
ctest = (CTest) Native.loadLibrary("ctest", CTest.class);
}
hence you see the JNA added prefix of lib and postfix of .so added to libctest (liblibctest.so)
LD_PRELOAD is used when you want to prefer one particular version of the same shared library over another, which doesn't apply here.
Define jna.library.path to point to your project root, and JNA should be able to find it.
Also make sure your library has been built as libctest.so and wasn't inadvertently named libctest.dylib.

WSImport WSDL artifacts in same package

I have a WSDL which has 3 schemas say Schema 1, Schema 2 and Schema 3 .
Schema 1 - Target_namespace_1
Schema 2 - Target_namespace_2
Schema 3 - Target_namespace_3
When i run the WSImport in cmd line on the WSDL file , it creates java artifacts in folders namely
Target_namespace_1, Target_namespace_2,Target_namespace_3.
This WSDL is used in another project and all the artifacts appear in a single package.
I have tried using the options in wsimport.exe but still not able to generate all the packages in a single package. Any advise in this regard will be very helpful
Assumed below WSDL includes multiple XSDs with different namespaces calling wsimport this way:
wsimport.exe -d C:/temp/generatedClasses -s C:/temp/sourceFiles C:/temp/myWsdl.wsdl
will give you a package structure like described in your question (e.g. own package per namespace)
You can use the parameter -p this way:
wsimport.exe -d C:/temp/generatedClasses -s C:/temp/sourceFiles -p blob.der.bob C:/temp/myWsdl.wsdl
And any output resides in the same package (your .java files would reside in C:/temp/sourceFiles/blob/der/bob)

Which is the environment variable for Mono/C# library DLLs?

I'm running the frozen Debian 7.0 Testing/Wheezy.
Here is my C# sample code:
using System.Windows.Forms;
using System.Drawing;
public class Simple : Form
{
public Simple()
{
Text = "Simple";
Size = new Size(250, 200);
CenterToScreen();
}
static public void Main()
{
Application.Run(new Simple());
}
}
I got the above C# WinForms code sample working in Monodevelop by using the System.Drawing and System.Windows.Forms references as well as in the command line when compiling with the following command:
mcs /tmp/Simple.cs -r:/usr/lib/mono/4.0/System.Windows.Forms.dll \
-r:/usr/lib/mono/4.0/System.Drawing.dll
I'm trying to make the mcs command work without needing to use the -r switch/parameter (which, by the way, I cannot find information on by looking through man mcs - I basically found this switch/parameter on some random website and it worked).
To check if it worked temporarily, I issued
export PATH=$PATH:/usr/lib/mono/4.0/System.Windows.Forms.dll:/usr/lib/mono/4.0/System.Drawing.dll
prior to issuing mcs /tmp/Simple.cs, which failed with the errors within the following output:
deniz#debian:~$ cd /tmp
deniz#debian:/tmp$ export PATH=$PATH:/usr/lib/mono/4.0/System.Windows.Forms.dll:/usr/lib/mono/4.0/System.Drawing.dll
deniz#debian:/tmp$ mcs Simple.cs
Simple.cs(1,14): error CS0234: The type or namespace name `Windows' does not exist in the namespace `System'. Are you missing an assembly reference?
Simple.cs(2,14): error CS0234: The type or namespace name `Drawing' does not exist in the namespace `System'. Are you missing an assembly reference?
Compilation failed: 2 error(s), 0 warnings
deniz#debian:/tmp$
The above output tells me that the mcs compiler/utility is not seeing the dll files but I don't know what else to try.
Any help in getting the WinForms and Drawing libraries to be automatically “looked at” would be greatly appreciated!
I'm trying to make the mcs command work without needing to use the -r switch/parameter
This is not possible, mcs will not look for libraries unless you tell it to look for them (which is done with -r:...).

Resources