I am trying to provide protection and encryption for some build artifacts that our code produces (The code is written in c++ and c# and we use visual studio) . The tool that I am using is a product called AxProtectorNet which belongs to Wibu-systems company. While doing the protection (using a batch file in which I passed the dlls and the protector tool location) for one dll i am getting the error saying "file protected\Ramin.dll is locked". I wonder what it means. Does it mean it's already protected? Or is it corrupted?
It's worth mentioning that we got the code from another company. So we don't know much about the details on the code.
Related
I will give you a brief description of my software before I ask questions.
So there is a front end C# code which provides the user interface and a back end C++ code that deals with the hardware.
The C# project creates an executable (.exe) file and the C++ project creates a DLL which talk with each other using pinvoke calls (import/export functions). All this worked fine on WEC7.
Now, we are moving to WEC2013 with Toradex. I downloaded the WEC2013 SDK from Toradex’s website and was able to port my code and build it on VS2013.
I copied all the required files on a USB and when I tried running it the C# exe is not able to communicate with the C++ Dll. The error I get is :
missingmethodexception can't find pinvoke dll “xyz.dll”
I have made sure the dll exists at the specified location. The dll also has the required export functions.
First I thought the function parameters in the export functions could be an issue, but I tried calling function which requires no parameter with the same result.
Any help will be really appreciated.
probably this is an easy one.
I have a solution that contains two projects:
a web page (asp.net)
a project that contains logic (Project B)
I am set up the web in a server and it loads ok, but when it needs to use the Project B I get an exception showing that it is searching a class in the path of the machine where the code was compiled. This image is the exception I am getting (in orange the path of the compilation machine):
How can I configure the web in order to tell where to search the files of Project B?
Really appreciate any help
I get an exception showing that it is searching a class in the path
of the machine where the code was compiled.
Wrong! C# compiles to intermediate language (IL) and this last one is the executable code which is also compiled to machine code using the JIT compiler or NGen-ing the IL..
You find that class file path because you're publishing your Web app using the Debug configuration and you're also including the .pdb files.
While I find that part of your question is a possible duplicate (see my close vote comment in the question itself), I wanted to add an answer to demystify your statement:
How can I configure the web in order to tell where to search the files
of Project B?
In .NET, executable code is compiled into assemblies, either executable or dynamically-linked libraries (DLL). That is, these class paths to your actual code location in your machine are just debugging information to make your life easier when looking and finding issues during some execution call stack.
The files names are from whatever machine the .pdb file for your assembly was generated on.
From MSDN:
A program database (PDB) file holds debugging and project state information that allows incremental linking of a Debug configuration of your program
Your problem looks like a database connection issue (which is explicitly said in the exception). Please check your connection string and make sure that your database is accessible.
Hi I am trying to find a way of executing code generated at runtime, without restarting the program.
My current workflow:
User uses my program to create some diagrams
User presses compile and C# code is generated from the users diagrams
The C# code is placed in a code file which exists in my project's hierarchy. The program is then restarted in order to use the newly generated code.
What I'm after though is changing Step 3, so I don't have to restart the program. Something like:
The C# code is run through the C# compiler which generates a DLL.
any errors are shown to the user
The DLL is then loaded into the program
Setup some links to the codes methods, so I can pass data to it and get output data
if this would work?
Look at the CSharpCodeProvider. It is intended for compiling a code in memory.
Can anyone tell clearly about the usage of header files and namespaces in C#?
Because in C++ I was using ******.h files to read library functions. And when I saw some sample programs in C# they were missing, Can anyone tell me why?
I'm using C# to develop a custom tool for a CAD application. Whenever I use the appropriate function to open the file (CAD file), the compiler is giving me an error stating that the function names which I supply are not available in the context. Here what does meant by context?
When I opened the help file of that CAD application the function which is responsible for opening the file has bee mentioned under a header file called uf_part.h. But there is an namespace called NXOpen.
I used the namespace as using NXOpen in Visual Basic, isn't that enough? DO I need to supply that header file as well? If so, how?
C# is more "programmer friendly". When dealing with files of the same project, instead of manually specifying "header file" every time, it will go and look in all the project files for a match according to the namespace.
To understand this, do the following steps:
Start new project in Visual Studio. (No matter what type, WinForms or Console)
Right click the project and add new class.
In your main class note you can see the new class you just added, without adding any header.
How this is done? Simply by having the same namespace to both classes. The .NET engine is smart enough to link all those classes together.
Now, when it comes to external code meaning code sitting in a different DLL file the trick is to add reference to that DLL (in Studio --> Right click project --> Add reference --> Browse) then you need to specify you are going to use that DLL by adding a using statement on top:
using ExternalDllName.ExternalNamespace;
That's about it. Unlike C++ you don't need to have .h file as .NET will automatically search the referenced DLL files for a match.
There's no such thing as header file in .net, because all needed metadata is contained in referenced assembly itself.
Have you referenced needed assembly in you project?
Also please mind that there's no such thing as "function" in C#, only class methods (which means that you have to specify object or static class in you call).
Also: General Structure of a C# Program
Compilers for modern languages, such as C# or Java store within compiled files information on the classes and methods they contain, and this information can be used to check the correctness of calls made from one source file to another or to library classes.
When C was invented disk space, memory and CPU power were precious resources and this approach would not have been possible. Header files were introduced to allow the compiler to check that different source files conformed to the same interface. When C++ was invented the approach described above could have been possible, but I guess that it was chosen to stick to the C one for compatibility reasons.
I can't find any good resources online about what this is. It's required in one of the steps for deploying a .NET assembly for use by COM, but there is no detail what it is or what it means.
As an example, here is something from the book I'm reading on Interop:
Next you need to create a resource script MyExampleAssembly.res with the following statement:
(This gets run at the VS command prompt in the directory where you just exported your .NET component using the Type Library Exporter Utility)
IDR_TYPELIB1 typelib "MyExampleAssembly.tlb"
What is IDR_TYPELIB1?
Also, it's not working for me. I have tried running this and it doesn't compile. I get a message "'IDR_TYPELIB1' is not recognized as an internal or external command".
It is a macro that's normally auto-generated when you use the unmanaged resource editor. Just use a constant, 1 is fine. You are also using the wrong tool to compile the resource script by the sound of it, you must run rc.exe. It translates your .rc file to a .res file that the C# compiler can use.
Embedding the type library is optional btw, it is not something that COM Automation requires. It is not a very good idea to do this in a managed project since the .tlb is generated after building the project. Instead of before, as happens in a native COM project. You create it with regasm.exe, /tlb option or the tlbexp.exe utility. Your client can do this too.