Re: Issue with NUnit and Silverlight integration

"Gulrajani, Raviraj" <[email protected]>
Newsgroups gmane.comp.windows.dotnet.nunit.user
Message-ID <04BED110EB41D247918E29051DFF7B28065B90F0@NYC-EXCLS2.dc1.doubleclick.corp>
Hi Charlie,

 

Thanks for the reply.

 

But I am already running the tests in STA. I have created a new Config
file for the project, which runs the Tests in STA.

 

Console.WriteLine(Thread.CurrentThread.GetApartmentState()); returns STA
on the Console.

 

Its when I try to create a new MediaElement in the test method, where I
see the test failing.

 

Thanks,

 

Raviraj

 

________________________________

From: Charlie Poole [mailto:[email protected]] 
Sent: Friday, March 07, 2008 1:51 PM
To: Gulrajani, Raviraj; [email protected]
Subject: RE: [Nunit-users] Issue with NUnit and Silverlight integration

 

This is new territory for me, so others may have better information. As
a first cut, based on experience

with Windows and Web Forms, I would try running the tests in the STA.
You use the config file

for the tests to do this - see NUnit's own NUnitTests.config for a
example.

 

Charlie 

	 

	
________________________________


	From: [email protected]
[mailto:[email protected]] On Behalf Of
Gulrajani, Raviraj
	Sent: Friday, March 07, 2008 7:25 AM
	To: [email protected]
	Subject: [Nunit-users] Issue with NUnit and Silverlight
integration

	Hello gang,

	 

	I am trying to use nunit for unit testing a project of mine.

	In the solution I have two projects:  MyProject (this is a
silverlight 2.0 project) and TestProject (this is a regular c# project.

	I reference the nunit.framework.dll and MyProject.dll in the
TestProject.

	 

	I create an instance of a class present in MyProject in the
'TestProject and then assert if the instance is null or not.

	 

	When I run the test through nunit, I get the below exception:

	 

	System.UnauthorizedAccessException : Invalid cross-thread access

	 

	The stack trace is below:

	 

	at MS.Internal.XcpImports.CheckThread()

	at MS.Internal.XcpImports.CreateObjectByTypeIndex(UInt32
typeIndex)

	at System.Windows.DependencyObject..ctor(UInt32 nativeTypeIndex)

	at System.Windows.UIElement..ctor(UInt32 nKnownTypeIndex)

	at System.Windows.FrameworkElement..ctor(UInt32 nKnownTypeIndex)

	at System.Windows.Controls.Control..ctor(UInt32 nKnownTypeIndex)

	at System.Windows.Controls.UserControl..ctor()

	 

	Could you please shed some light on the issue?

	 

	Thanks,

	 

	Raviraj

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

_______________________________________________
Nunit-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/nunit-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.