Managed C++ Error when using a snk file:: "missing the private key needed for signing" - managed-c++

Why am I getting this error when trying to sign a Managed C++ project using a .snk file.
"......SlimDX\build\vs2010\x86\Debug\VOS.snk' is missing the private key needed for signing"
Iv'e tried setting it in the project settings::
Key File =
$(ProjectDir)x86\$(Configuration)\VOS.snk
Delay Sign = No (/DELAYSIGN:NO)
And iv'e tried setting it in AssemblyInfo.cpp::
[assembly:AssemblyKeyFile("VOS.snk")]
[assembly:AssemblyDelaySignAttribute(false)]
I have both the .snk & .pfx files. What am I missing here? The .snk file is all I need in my C# .NET 3.5 project... Why will it not work in my managed c++ project as well? Do I need to use my pfx file also in some way?

Well somehow I was using a corrupt key or something, because when I got a new .snk file it all worked the way it should....

Related

VB.Net WebSite Get Assembly Version

We have a very old legacy VB.Net ASPX WebSite, not Web App, and I am trying to implement simple versioning. Either auto increment or manual as it doesn't matter.
So far I have tried putting the AssemblyInfo.vb file in the root folder and in the App_Code folder.
Then i have tried various implementations of the following;
Dim versionNumber As Version
versionNumber = Assembly.GetExecutingAssembly().GetName().Version
This only ever return 0.0.0.0.
I have also used;
Dim a As String = Assembly.GetAssembly(GetType(Business.EmailHelper)).GetName().Version.ToString()
The latter gets me a version as I am targeting a class library that has AssemblyInfo.vb in it.
I just can't seem to get the same for the WebSite.
Where do I place the AssemblyInfo.vb file in the WebSite so that I can read the version information?
Thanks.
To version the assembly for an ASP.Net Website project you need to precompile it. You also need to include the AssemblyInfo.vb either via a Page directive or the Web.config file. MSDN article on it here.

Copying/Moving App Code to New Project

Ok, I am in the process of breaking apart of intranet application (VS 2010 Web Site, ASP.NET Web Forms with VB code behind). During this process i'm trying to convert some of our our app_code files in to WCF rest service in a new project. However, when I copy or "add existing" vb files into the new "services" project. I get tons of errors including...
error BC30002: Type 'XXX' is not defined
warning BC40056: Namespace
or type specified in the Imports 'System.ServiceModel' doesn't
contain any public member or cannot be found. Make sure the
namespace or the type is defined and contains at least one public
member. Make sure the imported element name doesn't use any aliases.
From what i've read it may (or may not) have something to do with Assemblies and references that I just have very little knowledge on. I have added the namespaces from the current web.config to new project's web.config, and the files are identical. So there is something in the background that needs to be added to the new project I just don't know what its.
PLEASE HELP!!
THANKS
JOSH
UPDATE 1
So one of the errors i'm getting = "error BC30002: Type 'MailMessage' is not defined." Which is a namespace that is added to the web.config, which apparently isn't being picked up??? IDEAS?
I've come across a similar issue - not sure what the reasoning behind it is, but I got around it by creating a new .vb class with the same name as the one you want to copy, then copy and paste all the text from the old one to the new one. Save it, then it seems to like it - it didn't like me copying and pasting the actual file, nor did it like me adding existing files.
Hope this helps :/
This issue seems to be tied to the the differences between Web Application Projects versus Web Site Projects. Eventually I had to add different namespaces on the new project level.
Here is more info about WAP vs WSP....
http://msdn.microsoft.com/en-us/library/dd547590(v=vs.110).aspx

Can not write to sqlite db in packaged air

I can write to db when running in IDE(FB), while after packaging a air, the app wont write to sqlite db, Why? Thanks in advance.
The likely cause is that your installed Air application can't resolve the path to your sqlite file.
What I normally do is to use one of the static public properties of the File class to resolve my sqlite file from eg.
databaseConnection = new SQLConnection();
databaseConnection.addEventListener(SQLEvent.OPEN, onOpen);
databaseConnection.addEventListener(SQLErrorEvent.ERROR, onError);
databaseConnection.openAsync(File.applicationDirectory.resolvePath('mydb.sqlite'));
The key bit here is the File.applicationDirectory.resolvePath('mydb.sqlite') line, in this instance AIR will look for a file called mydb.sqlite in the directory that the application is installed into - in your development environment this would be the same as the bin-debug folder (or whatever folder you are compiling to).
Hope that helps, if not if you can post the code you are using , and what error you are getting I will try and help you further.
The most likely reason is that your DB file resides in the application directory, which is read only.
From Flex 3.5 Language Reference:
File.applicationDirectory—the read-only directory where the application is installed (along with any installed assets)
If this is the case, a possible but not only easy fix would be to just use File.applicationStorageDirectory.
Hope this helps.
N.

ASP.NET MVC 2.0 NHibernate Configure() issue

I have installed NHibernate for my ASP.NET web app although I'm getting a problem in real-time on the following line of code:
if (_sessionFactory == null)
{
_sessionFactory = new Configuration().Configure().BuildSessionFactory();
}
Looking at the inner exception the problem is this:
{"Could not find file 'D:\Websites\Test\Test\Test\bin\hibernate.cfg.xml'.":"D:\Websites\Test\Test\Test\bin\hibernate.cfg.xml"}
This makes sense, as the file doesnt exist in that location. This line of code is within my Core project. File hibernate.cfg.xml is currently in my Infrastucture project, not my Core. Should this be? I have copied the file into this location although I still get problems. If I manually copy the file into this location within windows explorer I then get the following error during runtime.
{"Could not load file or assembly
'Infrastructure' or one of its
dependencies. The system cannot find
the file specified.":"Infrastructure"}
Also, I'm missing DynamicProxy.dll as I'm using castle and I couldnt see a version of the DynamicProxy in the castle folder that I downloaded from http://sourceforge.net/projects/nhibernate/
any suggestions? I can see LinFu.DynamicProxy.dll within the download although it says I only need one of the folders, Linfu or Castle, and I'm using Castle for this experiment. Not sure if this has anything to do with it, just thought it might help.
any ideas? Many thanks,
James
About "Could not find hibernate.cfg.xml": you can either set it to "Copy to Output" (see this) or configure it as an embedded resource.
About "Could not load assembly Infrastructure": you're missing Infrastructure.dll in your bin, or one of its dependencies, just as the error says.
About missing DynamicProxy.dll: if you're using NHibernate 3.x all you need to use the Castle bytecode provider is NHibernate.ByteCode.Castle.dll and Castle.Core.dll

ASP.NET - How do I stop classes/dlls from one project being compiled into another project

I have one of those annoying problems where something that used to work stopped working.
Check out this code:
Assembly _abc_assembly = Assembly.LoadFile(“c:\junk\abcabstract\bin\abc.dll”);
ABC.ContentAttribute attribute;
attribute = (ABC.ContentAttribute)_abc_assembly.CreateInstance("ABC.TextAttribute");
ContentAttribute is defined in the dll.
Obviously, this should work. You should be able to cast an object to itself.
But it produces this error:
alt text http://www.yart.com.au/stackoverflow/compile1.png
This bug is discussed here http://www.yoda.arachsys.com/csharp/plugin.html which is how I got even this far. From this post I gather that the class ContentAttribute is somehow ending up in ABC.DLL and the website project's DLL.
The website project I have looks like this:
alt text http://www.yart.com.au/stackoverflow/compile2.png
Now ContentAttribute is not in this project, it is in the dll ABC.DLL. You can see that as I have expanded every branch and the file ContentAttribute.cs is not there.
Yet somehow it is ending up in the dll for the website creating a duplicating reference. ContentAttribute is somehow ending up in ABC.DLL and the website project's DLL.
Can anyone tell me:
a) Why is ContentAttribute in two dlls? I didn’t think including a dll in a project forced that code into the projects DLL.
b) How to stop it from happening?
By the way, I definitely don't want to change the website project into a website application if I can avoid it.
Notes:
Deleting the temporary ASP.NET files does not work. As soon as I compile my website project they get recreated.
alt text http://www.yart.com.au/stackoverflow/compile3.png
It's a namespace collision. It doesnt know which ContentAttribute to use since it is finding 2 in different namespaces/assemblies.
You may have an old copy of the DLL named differently. Delete your temporary ASP.Net directories and recompile.
To avoid in the future:
Use fully qualified names for your objects if you need to get it to work.
ABC.ContentAttribute ca = new ABC.ContentAttribute();
or if casting do the same
ABC.ContentAttribute ca =(ABC.ContentAttribute)ca2;
ABC.DLL is referenced by your website and it becomes part of it (it is in Bin folder). ASP.NET compiles your website and ABC.DLL is placed in temp location (C:\Windows...\Temporary ASP.NET Filse...). It gets loaded by ASP.NET automatically. You are trying to load ABC.DLL manually from different location (D:\junk\abcabstract\bin\abc.dl). Two assemblies do not match hence you get the error.
To stop this from happening you have to rethink your plugin architecture I guess. Can you give more information?
Update:
Why don't you fix it like this:
// Assembly _abc_assembly = Assembly.LoadFile(“c:\junk\abcabstract\bin\abc.dll”);
// ContentAttribute attribute;
// attribute = (ContentAttribute)_abc_assembly.CreateInstance("ABC.TextAttribute");
ContentAttribute attribute = new ContentAttribute();

Resources