|
That sounds about right.
I would just point out that assemblies run from a network share will have reduced permissions when using the default security settings for .NET. Depending on what your assemblies do, you may need to alter these settings to give your assemblies the necessary permissions.
Regards
Mark Smithson
|
|
|
|
|
Sorry for the long post, but I need some help. I'm writing a class that implements IComparer, and I'm having some problems. What do you make of this:
My class looks like this:
class RandomComparer : IComparer
{
private static Random c_random;
private static RandomComparer c_instance;
public static IComparer Default
{
get {return c_instance;}
} // End Default
static RandomComparer()
{
c_random = new Random();
c_instance = new RandomComparer();
} // End RandomComparer()
int IComparer.Compare(object objA, object objB)
{
// Are the objects different?
if (Comparer.Default.Compare(objA, objB) != 0)
{
// Get two random numbers.
int numberA = c_random.Next(0, m_maxSample);
int numberB = c_random.Next(0, m_maxSample);
// Compare them and return the results.
if (numberA > numberB)
return 1;
else if (numberA < numberB)
return -1;
} // End if the objects are not the same.
return 0;
} // End Compare()
} // End class RandomCompare
I use this class to sort an array like this:
string[] someArray = new string[] {"item 0", "item 2", ... "item N"};
Array.Sort(someArray, RandomComparer.Default);
Everything works fine most of the time, but every now and then the framework throws an exception that says:
"An unhandled exception of type System.ArgumentException occured in mscorlib.dll
Additional information: IComparer (or the IComparable methods it relies upon) did not
return zero when Array.Sort called x.CompareTo(x). x: value 7 x's type: String
The IComparer: RandomComparer"
If I set Visual Studio.NET to break for all exceptions, I get a different exception, this time it says:
"A first chance exception of type 'System.IndexOutOfRangeException' occured in mscorlib.dll
Addition information: Index was outside the bounds of the array."
If I elect to continue debugging in this case, the framework then throws the first exception.
I searched the Microsoft knowledge base, and did a Google search, but I couldn't find anything.
Sheesh! This should be a five minute programming task, but I've worked on this all morning long!
Has anyone ever run across this? Does anyone have any ideas?
|
|
|
|
|
OK, either my original post was too long for anyone to read or I'm the only person having this problem. Let me simplify things. Has anyone noticed flaky behavior from .NET when creating or using a custom IComparer? I'll probably submit this to Microsoft support, but that will take forever... In the meantime, has anyone run across this sort of problem?
|
|
|
|
|
Hi, Martin.
Most sort algorithms need stable comparison functions. Your function seems to be returning random results when the objects are different, so the .NET framework gets lost.
Suppose you have created a function where A > B > C > D. Your IComparable should be stable and NEVER return B > A > D > C.
Comparison is, too, a transitive function. So, if A > B and B > C, you can safelly assume that A > C. Your function does not guarantees that.
My latest article: GBVB - Converting VB.NET code to C#
|
|
|
|
|
Hello everybody,
I've dome some research for an Open Source DataGrid component for .NET but I couldn't find anything worth working with. What do you think of starting up a new project for a suite of Data-aware components that could be comparable to commercial ones?
Is there anybody interested on talking about that?
Valerio Santinelli
|
|
|
|
|
Anybody know if the functionality of the discretionary access control lists is in the .NET managed framework anywhere --- i.e. can I programatically add or remove user permissions for a given shared printer without getting down and dirty with the API?
'--8<------------------------
Ex Datis:
Duncan Jones
Merrion Computing Ltd
|
|
|
|
|
I've heard that some of these features can be found in the System.Management namespace. I have personally found it easier to just wrap the pertinent SDK calls using PInvoke. I seem to recall reading an article or two related to WMI and PInvoke/DACL stuff on this website. Try doing a search.
|
|
|
|
|
Can anyone explain to me why the text retrieved from a mutli-line textbox has CRLF instead of LF for new lines? And can I alter this behaviour?
I thought we'd seen the last of the whole dos vs unix thing
|
|
|
|
|
Well I guess a simplistic replacement strategy would be:
using System.Text.RegularExpressions;
...
someTextBox.Text = Regex.Replace(
myMultiLineString, "\n", "\r\n" );
and vice versa for reading text from a TextBox.
Does seem rather ugly to me though.
|
|
|
|
|
Hello
I want to customize my VS7 for editing php files.
The goal is :
1. that I can make file >> new and choice new php file
2. that I can use the Outlining functions
3. I can use the SPACE+CTRL for reconizing php keywords (Like userdat VC6 file.)
thank for help
|
|
|
|
|
I have created a Windows Form control and also an application that uses it.
When I reference the control, if I don't choose "copy local = true", the it throws a System.IO.FileNotFoundException.
What may be the reason?
|
|
|
|
|
Is the directory that contains the assembly in your search path? Your executable will need to be able to load the assembly at runtimne...
|
|
|
|
|
Yes, you are right...
In fact, the correct place for this assembly would be the GAC (Global Assembly Cache). However, I don't know how to tell my setup program to place the assembly into the GAC. (I am creating a Deployment Project)
|
|
|
|
|
Does anyone have any source examples that can read the metadata from a PE file? I have Serge Lidin's book _Inside Microsoft .NET Assembler_, but there seems to be a few errors in it, and some of the descriptions are a bit confusing.
Any help would be appreciated,
cmpwiz576
PS. This is my first post to CodeProject!!
|
|
|
|
|
Has anybody had any problems with the included version of Crystal Reports for Visual Studio after upgrading to VS.NET 2003/.NET Framework 1.1?
It seems like it's not liking to use a DataSet as a ReportSource anymore. If I go back to 2002/1.0 everything works just fine.
Ron
|
|
|
|
|
I'm running on Visual Studio.NET 2003. Is there a quick way to implement an interface via a keystroke or menu option? Some of the interfaces in .NET have many member that need to be implementented, so what I'm looking for is some sort of keystroke or menu option that will fill in empty functions for all the members that need to be implemented.
Thanks in advance.
Kyosa Jamie Nordmeyer - Cho Dan
Portland, Oregon, USA
|
|
|
|
|
OK, I figured out how to do this, but for some reason, the 'Implement Interface' is not on the context menu. Any ideas why?
Again, thanks in advance.
Kyosa Jamie Nordmeyer - Cho Dan
Portland, Oregon, USA
|
|
|
|
|
Is there any tracker rect in .Net WinForms (like CRectTracker in MFC) ?
|
|
|
|
|
Hi,
I need to access a particular .NET Windows Form DLL as ActiveX Control.
<OBJECT id="myControl1" name="myControl1" classid="PrintCtrl.Dll#PrintCtrl.Class1" VIEWASTEXT width="0" height="0">
< PARAM NAME="File" VALUE="http://localhost/" >
</OBJECT>
Now that this Dll needs to access and print from IE, I had to package as CAB file using VS.NET Setup and Deployment Project (CAB Project). Instead of DLL, I gave PrintCAb.cab. But now it is saying 'Object does'nt support this property/method'
How to refer the methods in the DLL if I give this CAB now?
Please advise...
Deepak Kumar Vasudevan
http://deepak.portland.co.uk/
|
|
|
|
|
I was wondering what kind of memory I use when I, for example, declare a new variable... Is it Ram, or disk swap? Do I have any control over that? Can I find out how much free memory a system has?
Thanks,
Andrei Matei
andreimatei@home.ro
|
|
|
|
|
When you declare a variable it gets created in RAM. If your available RAM is low then the system might swap some stuff to disk in order to free up some RAM, but even in that case your variable would stil reside in RAM. As far as I know you really don't have much control over that.
|
|
|
|
|
i want to know what kind of options does one have to capture video using .NET Framework?
urgent reply would be appreciated!
|
|
|
|
|
try searching for "video"...
"When the only tool you have is a hammer, a sore thumb you will have."
|
|
|
|
|
well i did for that matter, but the thing is i came up with a few techniques, i want to know if someone has implemented video capturing in .NET......so that i can get a jumpstart!
|
|
|
|
|
search THIS site for "video" there are loads of .net examples for video
"When the only tool you have is a hammer, a sore thumb you will have."
|
|
|
|