October 29, 2012

Load an assembly from a network location


Error:
Exception Message: Could not load file or assembly 'file:///Z:\PROJECT\bin\Debug\XYZ.dll' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)

Exception Message: An attempt was made to load an assembly from a network location which would have caused the assembly to be sandboxed in previous versions of the .NET Framework. This release of the .NET Framework does not enable CAS policy by default, so this load may be dangerous. If this load is not intended to sandbox the assembly, please enable the loadFromRemoteSources switch. See http://go.microsoft.com/fwlink/?LinkId=155569 for more information.


System.NotSupportedException: An attempt was made to load an assembly from a network location which would have caused the assembly to be sandboxed in previous versions of the .NET Framework. This release of the .NET Framework does not enable CAS policy by default, so this load may be dangerous. If this load is not intended to sandbox the assembly, please enable the loadFromRemoteSources switch. See http://go.microsoft.com/fwlink/?LinkId=155569 for more information.


Solution:
It will be solved if you add a simple magic ;-) line to YOURPROJECT.exe.config file 
- Open YOURPROJECT.exe.config file from bin folder
- Add <loadFromRemoteSources enabled="true" /> to <runtime> tag

October 18, 2012

CREATE FILE encountered operating system error 5


Problem:
- CREATE FILE encountered operating system error 5(Access is denied.)
- CREATE FILE encountered operating system error 5(failed to retrieve text for this error. Reason: 15105) while attempting to open or create the physical file 'PATH\FILE.mdf'.
- CREATE FILE encountered operating system error 5(Access is denied.) while attempting to open or create the physical file 'PATH\FILE.mdf'.

Solution:
- Go to Control Panel > Administrative Tools > Services
- Right click on SQL SERVER (BLAH BLAH) and select the Properties
- Stop service
- Go to Log On tab and change the Log on as: to Local System Account
- Apply and Start service again ans enjoy ;-)

October 16, 2012

Operation could destabilize the runtime


Problem:
- Devexpres has problem ... operation could destabilize the runtime
- have operation could destabilize the runtime with DXWindow ... devexpress
- devexpress problem with Visual Studio 2012


Solution:
There's just one solution, Upgrade to Devexpress v2012.1.6 and next versions ;-)

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;});