October 09, 2012

Mismatch between the processor architecture


Warning
There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "PATH\PROJECT.dll", "x86". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project.

Solution
1- In Visual Studio menu go to Build > Configuration Manager...
2- go to Platform column and select all x86 (it must be changed to Any CPU)
3- Click on <New...> and Select Any CPU
4- That's it, Compile All and Be Happy ;-)

October 05, 2012

The underlying connection was closed

Problem:
The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.


Solution:
Just add this line in your codes

ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(delegate{return true;});

September 24, 2012

CREATE DATABASE failed


Error:
Message:  CREATE FILE encountered operating system error 5(Access is denied.) while attempting to open or create the physical file "C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\XYZ.mdf".
Line Number: 2
Source: .Net SqlClient Data Provider
Procedure: 

Error:
Message: CREATE DATABASE failed. Some file names listed could not be created. Check related errors.
Line Number: 2
Source: .Net SqlClient Data Provider
Procedure:

Solution:
- Start application with Run as Administrator 
- Change the SQL Server service

September 09, 2012

Stop Compiler Warning Message

Problem:
- How can i stop warning ?
- The variable 'XYZ' is assigned but its value is never used
- but no compiler message for never used
- prevent compiler warning


Solution:
Just use of these lines before and after source code
#pragma warning disable
    [SOURCE CODE]
#pragma warning restore