.

test failed

test failed: System.BadImageFormatException : Could not load file or assembly ‘…’ or one of its dependencies. An attempt was made to load a program with an incorrect format

normally it is x86 vs x64 related issues. and you can check your build configuration and make sure they all compile in the same way.

in my case I had to set all individual project build properties to x86

 

[wcf: solution] The server was unable to process the request due to an internal error.

error: The server was unable to process the request due to an internal error.  For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the <serviceDebug> configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework 3.0 SDK documentation and inspect the server trace logs.

Solution

Enabling WCF trace:

Open config file in svcconfigeditor, from wizard, you can enable tracing and logging

STEP1:

Open config file in svcconfigeditor

STEP2:

Select Diagnostics option on left side, you will see Different tracing options on right side

STEP3:

If you just want to log soap request and response, you can choose Message Tracing
If you want trace service creation and all other activities, you can enable service tracing

Once you choose one of those options, you can choose, what level of tracing you want

(Like Verbose, or you want trace only error messages)

STEP4:

Click on Message Tracing, you will see different Message logging options, you can choose, you want to log Message at Transport level or Service level.

Reference:

http://msdn.microsoft.com/en-us/library/ms732009.aspx

Ok, Now I got trace file, How to view trace file:

Once you have log file, you can open client side trace and service side trace file in svctraceviewer and you can filter trace by different categories

http://windowssdk.msdn.microsoft.com/en-us/library/ms732023.aspx

Tracing and Logging Sample

http://msdn.microsoft.com/en-us/library/ms751526.aspx

MORE INFO ABOUT WMI AND PERF COUNTERS:

http://msdn.microsoft.com/en-us/library/ms735120.aspx

http://msdn.microsoft.com/en-us/library/ms735098.aspx

http://msdn.microsoft.com/en-us/library/ms751442.aspx

http://msdn.microsoft.com/en-us/library/ms751407.aspx

MORE INFO:

The Diagnostics tab enables you to turn performance counters on or off, enable or disable Windows Management Instrumentation (WMI), configure WCF tracing, and configure Windows Communication Foundation (WCF) message logging.

To control performance counters and WMI

Click the Diagnostics tab.

To turn on WCF performance counters, select the Enable Performance Counters check box. Clear the box to turn off the counters.

To turn on WMI, select the Enable WMI check box. Clear the box to disable WMI.

Configuring Tracing

You can create a WCF trace file with standard properties or set up a custom trace file.
To create a trace file with standard properties

Click the Diagnostics tab and click Tracing.

In the Diagnostics Tracing window that opens, click Create.

Choose a location for the trace file, and click Save.

Click OK to return to the Service Configuration Editor window.

To create a custom WCF trace file, you must configure both a source and listener.
To create a custom WCF trace file

Click the Diagnostics tab, and then click Tracing.

In the Diagnostics Tracing window that opens, on the Listeners tab, click Add.

Enter the parameters for your trace file. Clicking the TypeName line displays a “…” button. Click the “…” button to open Trace Listener Type Browser, which you can use to find preconfigured trace listeners that are already installed.

Note the Source section. Click Add in this section to open a dialog box with a drop-down menu listing available tracing sources. Select a tracing source and click OK.

To apply your changes, click OK on each window until you return to the main Service Configuration Editor window.

Configuring Message Logging

You can create a WCF message logging file with standard properties or set up a custom logging file.
To create a message logging file with standard properties

Click the Diagnostics tab and click Logging.

In the Message Logging Editor window that opens, click the Create button.

Choose a location for the log file and click Save.

Click OK to return to the Service Configuration Editor window.

To create a custom WCF message logging file, you must configure a source and a listener, as well as certain parameters.
To create a custom WCF message logging file

Click the Diagnostics tab and click Logging.

In the Message Logging Editor window that opens, on the Listeners tab, click Add.

Enter the parameters for your trace file. Clicking the TypeName line displays a “…” button. Click the “…” button to open the Trace Listener Type Browser, which you can use to find preconfigured trace listeners that are already installed.

Note the Source section. Click Add in this section to open a dialog box with a drop-down menu listing available tracing sources. Select a tracing source and click OK.

Click the Logging tab to set logging parameters. For example, you might want to set LogEntireMessage to False to help manage the size of log files.

To apply your changes, click OK on each window until you return to the main Service Configuration Editor window.

[resolved] Microsoft.Practices.ServiceLocation issues

Could not load file or assembly ‘Microsoft.Practices.ServiceLocation, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35′ or one of its dependencies. The system cannot find the file specified.

Solution: You might need the latest dlls (I did).

Here is the uptodate (as of 28/feb/2013) libraries if you want to replace yours:
CommonServiceLocator (or download from http://commonservicelocator.codeplex.com/)

 

[Resolved!] System.BadImageFormatException: The format of the file ‘xxx’ is invalid

I got the following error during unit testing.
System.BadImageFormatException: The format of the file ‘xxx’ is invalid

reason was that the project I tested was X86 but my testing application was “Any CPU”

Solution:
ensure that all your projects compile to the same platform, for example:
double click on your “properties” folder
set all individual platforms targets (of all your projects) to e.g. x86

that should resolve it.

– any other issues / solutions, please post below!

 

[RESOLVED] wordpress 3.5 visual tab issue/problem/bug after upgrade

If your visual editor on your wordpress site has broken due to the wordpress 3.5 upgrade and you get one of the following errors:

FIREFOX
TypeError: d is undefined
http://../wp-admin/load-scripts.php?c=1&load[]=jquery,utils,plupload,plupload-html5,plupload-flash,plupload-silverlight,plupload-html4,json2,quicktags&ver=3.5
Line 13

INTERNET EXPLORER
SCRIPT5007: Unable to get value of the property ‘canvas’: object is null or undefined
load-scripts.php?c=1&load[]=jquery,utils,plupload,plupload-html5,plupload-flash,plupload-silverlight,plupload-html4,json2,quicktags&ver=3.5, line 13 character 7535

CHROME
Uncaught TypeError: Cannot read property ‘canvas’ of undefined

You have 2 options to RESOLVE this:

1) Try to reinstall – click dashboard -> updates -> re-install now
2) or alternatively: edit wp-config.php and add this line at the bottom
       define(‘CONCATENATE_SCRIPTS’, false);

Unable to copy from obj\debug to bin\debug [solution/resolved]

Error 1 Unable to copy file “obj\x86\Debug\<>.exe” to “bin\x86\Debug\<>.exe”. The process cannot access the file ‘bin\x86\Debug\<>.exe’ because it is being used by another process. <>

This is due to a bug in Visual Studio (as it turns out that the file is locked by devenv.exe)

Here is the fix:

We need a pre-build action to remove the locked file.
Go to your project’s properties (in the solution explorer, right-click project and select the Properties option), click Build Events tab. Add this following script:

if exist “$(TargetPath).locked” del “$(TargetPath).locked”
if exist “$(TargetPath)” if not exist “$(TargetPath).locked” move “$(TargetPath)” “$(TargetPath).locked”

[RESOLVED] Threw an exception of type ‘Microsoft.VisualStudio.Debugger.Runtime.CrossThreadMessagingException’

threw an exception of type ‘Microsoft.VisualStudio.Debugger.Runtime.CrossThreadMessagingException’

 

solution:

textBox1.Invoke(       new MethodInvoker(           delegate { textBox1.AppendText("."); }));

SQL Server 2008 – Rule “Previous release of Microsoft Visual Studio 2008″ failed

Although you already have VS2008 SP1 installed.

Fix:

start -> run -> “cmd”

Setup /ACTION=install /SkipRules=VSShellInstalledRule

you will still get an error but it installs fine.

 

The SQL Server 2008 installer is checking the HKLM\SOFTWARE\Microsoft\DevDiv\XXX\Servicing\9.0\SP reg keys to tell if SP1 is installed. If you inspect those keys and find any SP keys with the value “0,” that is your road block.

 

Throwing Errors in SQL stored procedures

Best way to do it is as follows:

create function dbo.throwError()
returns nvarchar(max)
as
begin
    return cast('Error here.' as int);
end

and it will throw the following error:

Msg 245, Level 16, State 1, Line 1
Conversion failed when converting the varchar value 'Error here.' to data type int.

Collection was modified; enumeration operation may not execute

I get an error as follows:
Collection was modified; enumeration operation may not execute

for the following code:

 

foreach (Comment comment in comments)
{
    if (comment.IP == IPtoBan)
    {
        p.RemoveComment(comment);
    }
}

 

you can fix this by replacing the first line with this:

foreach (Comment comment in new System.Collections.Generic.List<Comment>(comments))