|
I'm using NUnit to test my application but it is giving me odd error messages that I have not seen before. I'm at a loss to think what configuration change I have made that would break NUnit. (Or what configuration changes I made at all) The application is new, so these are new unit tests fixtures. I also upgraded to NUnit 2.2.7 in case there was a problem with the previous version (no luck). My application runs okay if I launch it, yet I cannot test it.
Here is the message produced by using the NUnit console through TestDriven.NET:
------ Test started: Assembly: NOsm.Dao.Testing.dll ------<br />
<br />
TestCase 'M:NOsm.Dao.Testing.BookmarkDaoTest.SimpleTest'<br />
failed: Could not load file or assembly 'NOsm.Dao.Testing' or one of its dependencies. An attempt was made to load a program with an incorrect format.<br />
System.BadImageFormatException: Could not load file or assembly 'NOsm.Dao.Testing' or one of its dependencies. An attempt was made to load a program with an incorrect format.<br />
File name: 'NOsm.Dao.Testing'<br />
at System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)<br />
at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)<br />
at System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)<br />
at System.Reflection.Assembly.Load(String assemblyString)<br />
at TestDriven.TestRunner.AdaptorTestRunner.Run(ITestListener testListener, ITraceListener traceListener, String assemblyPath, String testPath)<br />
at TestDriven.TestRunner.ThreadTestRunner.Runner.Run()<br />
<br />
WRN: Assembly binding logging is turned OFF.<br />
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.<br />
Note: There is some performance penalty associated with assembly bind failure logging.<br />
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].<br />
<br />
<br />
<br />
0 passed, 1 failed, 0 skipped, took 0.89 seconds.
The code for SimpleTest is:
[Test]
public void SimpleTest()
{
Assert.IsFalse(true);
}
If I use the NUnit GUI I get a slightly different exception:
System.IO.FileNotFoundException...<br />
<br />
Server stack trace: <br />
at System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)<br />
at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)<br />
at System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)<br />
at System.AppDomain.Load(String assemblyString)<br />
at NUnit.Core.Builders.TestAssemblyBuilder.Load(String assemblyName)<br />
at NUnit.Core.Builders.TestAssemblyBuilder.Build()<br />
at NUnit.Core.Builders.TestAssemblyBuilder.Build(String testName)<br />
at NUnit.Core.TestSuiteBuilder.Build(String assemblyName, String testName)<br />
at NUnit.Core.SimpleTestRunner.Load(String assemblyName, String testName)<br />
at NUnit.Core.SimpleTestRunner.Load(String assemblyName)<br />
at NUnit.Core.ProxyTestRunner.Load(String assemblyName)<br />
at NUnit.Core.ProxyTestRunner.Load(String assemblyName)<br />
at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs)<br />
at System.Runtime.Remoting.Messaging.StackBuilderSink.PrivateProcessMessage(RuntimeMethodHandle md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs)<br />
at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg, Int32 methodPtr, Boolean fExecuteInContext)<br />
<br />
Exception rethrown at [0]: <br />
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)<br />
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)<br />
at NUnit.Core.TestRunner.Load(String assemblyName)<br />
at NUnit.Util.TestDomain.Load(String assemblyFileName, String testFixture)<br />
at NUnit.Util.TestLoader.LoadTest(String testName)
Any help would be appreciated.
ColinMackay.net
Scottish Developers are looking for speakers for user group sessions over the next few months. Do you want to know more?
-- modified at 8:06 Sunday 26th March, 2006
|
|
|
|
|
Okay - I've tracked down the problem. Somehow or another the project properties for the testing assembly were set to build for a 64-bit platform. I'm not sure how that happened - but it's fixed now.
ColinMackay.net
Scottish Developers are looking for speakers for user group sessions over the next few months. Do you want to know more?
|
|
|
|
|
Has anyone come across a Grid Computing project in .NET? I scoured the Internet but couldn't find anything much?
|
|
|
|
|
Funny, I find quite some on a simple search like this[^]...
---
b { font-weight: normal; }
|
|
|
|
|
I have a listview control on my form. How can I check if an item is selected or not? If I use
ListView1.FocusedItem.Index
and an item isnt selected, i get an error. How should I get around this?
|
|
|
|
|
|
|
Imho, you're better off examining the list view's SelectedIndices or SelectedItems property.
/ravi
My new year's resolution: 2048 x 1536
Home | Music | Articles | Freeware | Trips
ravib(at)ravib(dot)com
|
|
|
|
|
Hi all,
I have an application, where I want to create and place controls (textboxes, labels) on an empty form on runtime loaded from a database. Is there a way to do that? And how can I reference to these controls from an SQL commandstring ?
So I want to supply the user only these input controls, needed for the specific loaded SQL command
example:
"SELECT * FROM database where ID = " + Dyn_Created_Textbox.Text.ToString();
Do you have some ideas ?
Tnx in advance !
Frank
|
|
|
|
|
Hello, I`m scaned a picture and set the size height 10cm width 10cm, now when I load that picture, I can`t find these parameters, I can only find number of pixels, but nothing about size in centimetres.
sring path;
Bitmap image1;
path= OpenFile();
image1 = new Bitmap(@path, true);
}
//---------------------------------------
private string OpenFile()
{
OpenFileDialog dlgOpenFile = new OpenFileDialog();
dlgOpenFile.ShowReadOnly = true;
if (dlgOpenFile.ShowDialog() == DialogResult.OK)
{
string path = dlgOpenFile.FileName;
return path;
}
return null;
}
|
|
|
|
|
The size in centimeters is not stored in the file. What you are looking for is the resolution of the image, e.g. the PPI (or DPI) setting.
PPI stands for Pixels Per Inch. Often the less accurate term DPI is used, which stands for Dots Per Inch.
From the size in pixels and the resolution, you can calculate the size of the image in inches, then you convert that in centimeters.
If you for an example get this information from the file:
int ppi = 600;<br />
int widthInPixels = 2362;<br />
int heightInPixels = 2362;
The you can calcluate the size:
double widthInInches = (double)widthInPixels / (double)ppi;
double widthInCentimeters = widthInInches * 2.54;
...and the same way for height.
---
b { font-weight: normal; }
|
|
|
|
|
Thanks, You very helped me.
|
|
|
|
|
hi there.
i m making a interior decorator tool in c# i want to provide the mouse functionality for drag and drop and resizing the object.plz provide me some solution
khusboo
|
|
|
|
|
I have 3 classes:
class Element
{
public string name;
public string attribute;
public string innerText;
public virtual void add(Element e) { }
}
class CompositeElement : Element
{
private Element[] element;
public CompositeElement(string name, string attribute)
{
this.name = name;
}
public override void add(Element element)
{
}
}
class Root : CompositeElement
{
public Root(string name)
{
this.name = name;
}
}
When I build this project inluding 3 classes above, the error happens:"No overload for method 'CompositeElement' takes '0' arguments"
I really don't understand, can u expain to me?
Thanks,
Hung.
Hung
-- modified at 4:23 Sunday 26th March, 2006
|
|
|
|
|
When you create an object, the constructor for the class is always called, and also the constructors of all the classes that the class inherits.
You haven't specified a constructor for the Element class, so an empty constructor will automatically be created, just as if you had included this in the class:
public Element() {}
As you have specified a constructor for the CompositeElement class, no empty constructor is created. However, a call to the empty constructor of the Element class is done, just as if you had written:
public CompositeElement(string name, string attribute) : base() {<br />
this.name = name;<br />
}
The same happens in the constructor of the Root class. A call is made to the (non-existent) empty constructor of the CompositeElement class:
public Root(string name) : base () {<br />
this.name = name;<br />
}
To make the code work, you either add an empty constructor to the CompositeElement class, or specify the base constructor call in the Root constructor:
public Root(string name) : base (name, string.Empty) {<br />
}
---
b { font-weight: normal; }
|
|
|
|
|
I'm using PPC2003 with Cleartype mode screen. How i can draw a text without cleartype mode in GDI+ in CF 2.0
Nothing
|
|
|
|
|
How can I get the text of a prticular item in a listview? I searched online and found this
strItem = lvPurchaseDetails.Items(i).Text
Whats the equivalent of this in C#?
|
|
|
|
|
Mridang Agarwal wrote: Whats the equivalent of this in C#?
That looks like C# to me!
Modified at 11:02 Sunday 26th March, 2006
[edit]
Ah - I just noticed the ()s. Use [] instead.
[/edit]
/ravi
My new year's resolution: 2048 x 1536
Home | Music | Articles | Freeware | Trips
ravib(at)ravib(dot)com
|
|
|
|
|
Pretty much the same:
strItem = lvPurchaseDetails.Items[i].Text;
or if you want the text of a particular subitem:
strItem = lvPurchaseDetails.Items[i].SubItems[i].Text;
|
|
|
|
|
my bad...I've been working with VB for so long that I forgot to replace the () with [].
|
|
|
|
|
and In Addition of what added above if you want to get the Focused Item or Line Text use:
//to get the first column Item
str_item = listView1.FocusedItem.Text;
//to get the first column item key
str_item_key = listView1.FocusedItem.ImageKey;
//to get all the text in the line selected
string[] str_Items = { listView1.FocusedItem.SubItems[0].Text , listView1.FocusedItem.SubItems[1].Text,...//depending on the numbers of Columns you Have Ehere Column 0 is the first column and not the first column in subitem
Have a Good Day
|
|
|
|
|
I implement Project to GIS(ESRI) and use C#, I used Map Control view Detail Map on Form. How wiil I do Use algorithm "Floyd" find the fastest/shortest way the two placesCan U share Code or Exameple for Me (send to dong.nguyendinh@gmail.com)Thanks very much AnhTin
|
|
|
|
|
I am trying to save a toolbar state to registry for later restore. But i seem unable to work with the Win32 API correctly. Can someone help? The problem is with the TBSAVEPARAMS struct. It wants a handle to the registry key (HKEY_LOCAL_MACHINE in this case) but where do i get this? I have tried passing the HKEY_LOCAL_MACHINE const 0x80000002 but i get a memory cannot be read error when i execute SendMessage TB_SAVERESTORE. I have tried the NET Registry.LocalMachine but i am unable to turn this into a pointer needed for the struct.
So what options are available? Is this impossible in NET? Below is the code i am using.
[StructLayout(LayoutKind.Sequential)]
public struct TBSAVEPARAMS
{
public UIntPtr hkr;
public string pszSubKey;
public string pszValueName;
}
[DllImport("user32.dll")]
public static extern int SendMessage(
IntPtr hWnd,
uint msg,
bool wParam,
Win32Struct.TBSAVEPARAMS lParam);
// open registrykey
// create key if needed
RegistryKey key = null;
string regKey = @"SOFTWARE\TEST";
key = Registry.LocalMachine.OpenSubKey(regKey, true);
// check errors
if (key == null)
{
return;
}
// close registry key
key.Close();
// get toolbar handle
IntPtr hWndToolBar = TrayIcons.GetIconTrayWnd();
// set up restore struct
Win32Struct.TBSAVEPARAMS tbSaveParams = new Win32Struct.TBSAVEPARAMS();
tbSaveParams.hkr = (UIntPtr)Win32Const.HKEY_LOCAL_MACHINE;
tbSaveParams.pszSubKey = regKey;
tbSaveParams.pszValueName = "Toolbar";
// save tray icon state
int result = Win32Windows.SendMessage(hWndToolBar,
(uint)Win32Const.TB_SAVERESTOREA, true, tbSaveParams);
Debug.WriteLine("result: " + result);
|
|
|
|
|
I found that one has to us process shared memory when communicating with windows OS toolbars; I thought this only applied when reading back structs in a SendMessage. Below is update of my code. I do not get any errors this time, but nothing happens. No registry key value is created, nothing. I probably need someone with PInvoke experience to OK my code ot NOT. That would help.
// get toolbar handle
IntPtr hWndToolBar = TrayIcons.GetIconTrayWnd();
// get handle to other process
// open process for all access or get access denied error
int processID = 0;
int threadID = Win32ProcessThread.GetWindowThreadProcessId(
hWndToolBar, ref processID);
IntPtr hProcess = Win32ProcessThread.OpenProcess(
Win32Const.PROCESS_ALL_ACCESS, false, processID);
// set up shared memory for struct
// make it big enough to hold dynamic data
int bufferSize = 16000;
IntPtr hGlobalBuffer = Win32Memory.VirtualAllocEx(
hProcess, IntPtr.Zero, bufferSize,
Win32Const.MEM_RESERVE | Win32Const.MEM_COMMIT,
Win32Const.PAGE_READWRITE);
// allocate local memory to hold struct
IntPtr hLocalBuffer = Marshal.AllocHGlobal(bufferSize);
// set up save struct
Win32Struct.TBSAVEPARAMS tbSaveParams = new Win32Struct.TBSAVEPARAMS();
string regKey = @"SOFTWARE\TEST";
tbSaveParams.hkr = (UIntPtr)Win32Const.HKEY_LOCAL_MACHINE;
tbSaveParams.pszSubKey = regKey;
tbSaveParams.pszValueName = "IconsBackup";
// convert struct to pointer
Marshal.StructureToPtr(tbSaveParams, hLocalBuffer, false);
// put struct in place
Win32Memory.WriteProcessMemory(hProcess, hGlobalBuffer,
hLocalBuffer, bufferSize, 0);
// save tray icon state
// no return value
Win32Windows.SendMessage(hWndToolBar,
(uint)Win32Const.TB_SAVERESTOREA, true, hLocalBuffer);
// clean up
Win32Memory.VirtualFreeEx(hProcess, hGlobalBuffer,
bufferSize, Win32Const.MEM_RELEASE);
Marshal.FreeHGlobal(hLocalBuffer);
Win32ProcessThread.CloseHandle(hProcess);
|
|
|
|
|
Hi.Im a beginner in C# and Im trying to understand the meaning of this function:
public Complex(double r, double i)
{
x = r;
y = i; }
public Complex add(Complex c)
{
x += c.x;
y += c.y;
return this;
}
Anybody can explain me in simple words what is the meaning of this?
Best regards
|
|
|
|
|