How to use Elmah in Visual Studio non-ASP.Net library project - elmah

We need to use Elmah in a non-ASP.Net project.
In this library project, Elmah should log all uncaught exceptions and we should also be able to log or raise exceptions.
We have done this in web context but not in a library project. How can we achieve this or where can we find information about it?

Related

Is it possible to create a static library C++ with Visual Studio 2013 Community Edition?

I had a C/C++ Visual Studio 2013 Community Edition project that was defined to generate a DLL, and I'm having a lot of misery with "undefined symbols" which I wanted to use in another project, so I decided to see what it would give if I changed the project settings so that it would generate a static library instead.
So in the Properties window of the project I went to
Configuration Properties > General > Project Defaults > Configuration Type
and set the Configuration Type to Static Library
The target extension is .lib.
When I do a rebuild I still get a fresh dll file in my Release folder, as well as a lib, and the DLL file is much bigger than the lib file. This makes the lib file look like an "export lib" file and it looks like nothing has changed.
This still happens if I stop and restart Visual Studio.
Am I missing something or does this look like a bug to you?
In Configuration Properties - C/C++ - Runtime Library change setting to Multi-threaded (/MT) for Release configuration and to Multi-threaded Debug (/MTd) for Debug configuration.
Also, check Configuration Properties - General - General - Target extension is set to .lib.
Check settings for all configurations (Release and Debug if you use them).
Why have you changed your project type? If you need DLL, build DLL. Post exact errors received during DLL compilation. Perhaps you missed some dllexport/dllimport declspecs.
Regarding .lib: are you sure, that DLL is generated during build? Perhaps it is the output from previous (DLL) configuration? Have you tried to compile test app using this .lib? Perhaps it is valid and compiled properly?
Another matter: have you removed all dclspecs from function signatures after project type change? When building static library, none of them are applicable.

How do I know if a project is MFC application

My friend has given me a visual studio project , with lots of files.
I know for sure that it is C++ application.
But I want to verify that if it is an MFC application or not.
The issue is since this project has been developed on a higher version (VS 2013) than mine (VS 2010), it is not opening in VS 2010.
So I thought I will make a new project and then gradually add these files.
But When I try to make a new project , I have many options to choose , such as MFC, win32 etc.
I guess it is an MFC application. But to be sure I want to verify that this project is indeed an MFC application. How do I do this ? Especially by just looking at the project files!
Look into your source files and check if afx.h or afxwin.h is included any where.
Project Settings are secondary. Only if such a Header file is used in the Project the MFC libraries are included in the link phase.
You would probably be better off checking the source files, not the project file. For sure, the MFC library need to be present in the project file, but that option could have been left on accidentally.
You could search the source files for CWinApp, which is the class MFC applications need to be derived from. Also, you could try this page on MSDN, which will give you some idea about source and header files typically found in an MFC project.
VS2010 and VS2013 uses XML for .sln/.vcxproj files. Just create a minimal solution in VS2010. Then use a good text editor or even a file comparer to adjust settings inside the .vcxproj.
Great syntax changes occurred between VS2008 and VS2010. But since then most XML tags were kept unchanged between VS2010 and VS2013.

How to tell Visual Studio to use a different source code directory to debug into a library?

I provided clients with a C++ class library that they use in one of their C++ project.
They want me to investigate when a specific assert happens in the library, and sent me their client code to debug it.
I reproduced the assert on my computer, and was prompted by Visual Studio to specify a directory containing the source code to the library, for debugging.
I selected my development directory, but noticed that when navigating the call stack in Visual Studio, it directed me to wrong places in the source code. I realized this was because the directory I notified contained newer source code for the library (not the source code that was used to build the library that was sent to the client).
Fortunately, I have the source code that was used to build the library that was sent to the client. Unfortunately, I do not know how to tell Visual Studio to use this source code directory instead of the one I erroneously specified before.
How can I change it?
Try changing the name of the directory...
This should force Visual Studio to ask again for a directory, since it will no longer be able to find the code...
Try editing the Debug Source Files page.
This property page specifies where the debugger will look for source files when debugging the solution.
To access the Debug Source Files property page, right-click on your Solution in Solution Explorer and select Properties from the shortcut menu. Expand the Common Properties folder, and click the Debug Source Files page.
Source

Windows form application using Visual Studio c++, that links to a CUDA project

I am trying to implement a Windows Form Application using Visual Studio C++ that links to a CUDA project.
I created WFA.
Then I try to dynamically link the application to CUDA project by browsing the .dll in the Add Reference part of the Project Properties. But it said "Could not add ... it is not a .NET assembly or registered ActiveX control".
Thus I add the .obj of the CUDA project to the Linker->Input->Additional Dependencies part with the .lib files that are required to run CUDA in WFA project. Then I got "fatal error LNK1313: pure module detected; cannot link with ijw/native modules" error.
I changed the Common Language Runtime Support from "Pure MSIL Common Language..." to "Common Language..." but then msvcrtd.lib and libcmt.lib is conflicted. This error disappears when the .obj files of CUDA project are deleted from the "Additional Dependencies".
Since CUDA project's runtime is MT and WFA project's is MT dll, this error occurs. I changed the runtime of WFA to MT, but then "error D8016 : '/MTd' and '/clr' command-line options are incompatible" error occurs.
Since /clr is required for "System::" being recognized, I cannot get rid of the /clr option.
Do you have any suggestion to create a windows form application using Windows c++ that links to a cuda project in the easiest way? Or if there are easier way I would be glad to hear them.
I think your WFA app is a managed C++ .NET application using CLR. You are trying to include the unmanaged CUDA DLL as if it were a CLR Assembly or a COM Object. Thus VS is saying /MT (use unmanaged Multi-Threaded C run-time) and /CLR is not compatible.
So you need to either wrap the CUDA DLL in CLR object or use a .NET Binding for CUDA in your project. Try downloading CUDA.NET and incorporate that into you project as reference.
http://www.hoopoe-cloud.com/Solutions/CUDA.NET/

How do I install Crypto++ in Visual Studio 2010?

I downloaded http://www.cryptopp.com/#download 5.6.1 and have no clue that to do at this point. I am a total noob and need good instructions. thanks.
Directly from the readme (Which can be found here Crypto++ Svn Trunk):
* MSVC-Specific Information *
On Windows, Crypto++ can be compiled into 3 forms: a static library including all algorithms, a DLL with only FIPS Approved algorithms, and a static library with only algorithms not in the DLL. (FIPS Approved means Approved according to the FIPS 140-2 standard.) The DLL may be used by itself, or it may be used together with the second form of the static library. MSVC project files are included to build all three forms, and sample applications using each of the three forms are also included.
To compile Crypto++ with MSVC, open the "cryptest.dsw" (for MSVC 6 and MSVC .NET 2003) or "cryptest.sln" (for MSVC 2005 - 2010) workspace file and build one or more of the following projects:
cryptopp - This builds the DLL. Please note that if you wish to use Crypto++ as a FIPS validated module, you must use a pre-built DLL that has undergone the FIPS validation process instead of building your own.
dlltest - This builds a sample application that only uses the DLL.
cryptest Non-DLL-Import Configuration - This builds the full static library along with a full test driver.
cryptest DLL-Import Configuration - This builds a static library containing only algorithms not in the DLL, along with a full test driver that uses both the DLL and the static library.
To use the Crypto++ DLL in your application, #include "dll.h" before including any other Crypto++ header files, and place the DLL in the same directory as your .exe file. dll.h includes the line #pragma comment(lib, "cryptopp") so you don't have to explicitly list the import library in your project settings.
To use a static library form of Crypto++, make the "cryptlib" project a dependency of your application project, or specify it as an additional library to link with in your project settings. In either case you should check the compiler options to make sure that the library and your application are using the same C++
run-time libraries and calling conventions.
If you have any questions feel free to ask and i'll update the anwser with my responses.
I downloaded http://www.cryptopp.com/#download 5.6.1 and have no clue what to do at this point...
This is a very late answer, but the project has released some new files to help folks use Visual Studio 2010 and above.
The project had to release the updated files because VCUpgrade (provided with Visual Studio 2010) does a fairly poor job with this particular project. It has been a source of problems for a few years, and even visually impaired users were commenting about it. The problems were not fixed in VS2012, VS2013 and VS2015, so we don't believe Microsoft has any intentions of fixing the problems.
To use the updated files, download the latest Crypto++ release from the website. Then, visit the Crypto++ wiki and fetch vs2010.zip from the page Visual Studio. Unzip vs2010.zip over the Crypto++ files. Finally double-click the file called cryptest.sln to have Visual Studio open the solution file.
The Crypto++ wiki page also offers project files that provide dynamic runtime linking for both VS2005 and VS2010.
If you convert cryptest.sln from VS2005 to VS2010, you will meet a problem. When you compile source code, the compiler will show an error:
c1xx : fatal error C1027: Inconsistent values for /Ym between creation and use of precompiled header
You can resolve this problem by:
Going to Project Properties --> Configuration Properties --> C/C++ --> Precompiled Headers
Changing it to "Not Using Precompiled Headers"
You'll need to compile the library before using it with anything. You can't just install it. Here is a page from their wiki about compiling the library: http://www.cryptopp.com/wiki/Compiling