|
I solved it!
Found a good article on this URL
http://support.microsoft.com/?kbid=811658
Rickard
|
|
|
|
|
Hi,
I have now debugged my application and the string seems to be alright, but it
still doesn´t work, or actually it worked for a while, but suddenly
the same error occured again.
Could this be some kind of access problem?
Could it make a difference in I run the com in process or out of process?
Rickard
|
|
|
|
|
No, it would be an access problem if one client could access it via your COM component but another client couldn't, unless they were running with different credentials (something you have to manually do through several steps). This sounds more like a marshaling problem as I mentioned before.
Your COM component can only run as an out-of-process server if it is a stand-alone executable (.exe), so that's not even a valid case.
Since it worked before, you're obviously doing something right. Since it changed, you should figure out what changed. Two compiled applications don't magically change. If this is a marshaling problem, make sure you understand that Windows 9X/ME (Windows) use ASCII while Windows NT/2000/XP(/future versions of Windows) (Windows NT) use Unicode. I can't remember exactly how VB handles strings, but you can code your .NET applications to P/Invoke methods using either ASCII or Unicode depending on the OS type, which it will automatically do for you (see CharSet.Auto ). I don't remember exactly how VB deals with the different OSes. Find out how that works and make sure your .NET application marshals the string accordingly appropriately on either of the Windows OS system type.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
One other quick thought, not likely but you might check permissions and the creditials being used.
Rocky <><
www.HintsAndTips.com
|
|
|
|
|
Thanks, will keep this in mind.
Rickard
|
|
|
|
|
Hi,
I have now debugged my application and the string seems to be alright, but it
still doesn´t work, or actually it worked for a while, but suddenly
the same error occured again.
Could this be some kind of access problem?
Could it make a difference in I run the com in process or out of process?
Rickard
|
|
|
|
|
I have created my own Rebar Control and I am having issues on Windows 2000 machines.
When creating the handle it throws an Win32Exception with the error "Invalid window class name". It works fine on Windows XP machines.
The following is my CreateHandle method and CreateParams property. Any ideas?
protected override void CreateHandle()
{
if (!RecreatingHandle)
{
// Initialize Cool Bar Common Control
INITCOMMONCONTROLSEX initCommonControls = new INITCOMMONCONTROLSEX(); // I set Size field in constructor
initCommonControls.Flags = InitCommonClasses.COOL_CLASSES | InitCommonClasses.BAR_CLASSES;
SafeInterop.InitCommonControlsEx(initCommonControls);
}
base.CreateHandle(); // <-- Exception thrown here
}
protected override CreateParams CreateParams
{
[SecurityPermission(SecurityAction.LinkDemand, Flags=SecurityPermissionFlag.UnmanagedCode)]
get
{
CreateParams createParams = base.CreateParams;
createParams.ClassName = Interop.REBARCLASSNAME;
createParams.Style |= (int)(CommonControlStyles.NORESIZE | CommonControlStyles.NODIVIDER | CommonControlStyles.NOPARENTALIGN);
if (_Borders)
{
createParams.Style |= (int)RebarStyles.BANDBORDERS;
createParams.Style |= (int)(RebarStyles.VARHEIGHT | RebarStyles.AUTOSIZE);
return createParams;
}
}
}
|
|
|
|
|
You must make sure that your window class is registered using RegisterClass(Ex) API. InitCommonControls does this for classes defined in the common controls library, but any custom classes must be registered by you.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
I found out what is was. The INITCOMMONCONTROLSEX structure had the size and flags fields the wrong way, so the call to InitCommonControlsEx was failing. It's just weird that it worked fine Windows XP, sometimes is really bad for developing on, because it hides errors.
|
|
|
|
|
Hey guys!
How can i mix events in C#?
I want make a function what only runs when the mouse button is pressed, and the mouse's moving.
MS Visual Studio.NET 2003
C#
|
|
|
|
|
Here's an idea: How about in the OnMouseDown set a flag to say the mouse is pressed, in the OnMouseUp reset the flag back to its initial state. Then in the OnMouseMove event you can check the status of the flag to determine if the button is pressed or not.
--Colin Mackay--
EuroCPian Spring 2004 Get Together[^]
|
|
|
|
|
Hello:
Look at the next C++ code:
1) Defining map
const int cols=15;
struct stTot {
string strDesc;
double fTots[cols];
} myTot;
map<int, stTot> mpLis;
map<int, stTot>::iterator it;
2) Loading map
int iCnt = 0;
myTot.strDesc = (LPCTSTR)some_string;
for (int v=0; j<cols; myTot.fTots[j++]=0);
mpLis[iCnt] = myTot;
3) Extracting data from map
it = mpLis.find(some_value)
for (f=0;f<cols;f++)
{
monto_n3[f] += monto_pf[f];
(*it).second.fTots[f] = monto_pf[f];
}
In spite of some things that could be optimized in this code, it looks “elegant and powerful”, question is: How can I do this in C# so it looks elegant and powerful also?
I know that C# has System.Collections.Hashtable but it does not seem to solve the previous code. Who can surprise me?
Many, many thanks if you answer me.
Best regards
Eduardo Gironas.
|
|
|
|
|
Please do not re-post - continue the original thread.
What you're code is using is an enumerator. The Hashtable and other collections support this, too. See Hashtable.GetEnumerator , which returns an IDictionaryEnumerator . Other collections and lists (those that implement IEnumerable , which ICollection and IList do, so any of their implements do as well) return an IEnumerable .
If the Hashtable doesn't work for you, there are plenty of other collections and lists in System.Collections and System.Collections.Specialized that can. If you don't like the provided implementations, write your own ICollection , IList , or IDictionary implementation.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Heath:
Many thanks for your answer.
The real problem is with the structure:
struct stTot {
string strDesc;
double fTots[cols];
} myTot;
I cannot replicate this in C#. I tried many alternatives but I do not really know how to use it (the structure) during the Hashtable loading and recovery of data. A non elegant solution is to join every field that is in the mentioned structure into an string variable and then split them during recovery.
Best regards
|
|
|
|
|
public struct myTot
{
public string strDesc;
public double[] fTots;
} As you can see, there are a few limitations due to either the language specifications or the .NET Framework.
As far as putting this in a collection or Hashtable , the default, non-specialized implementations take objects as both keys and values. Ever class or value type (which a struct is) derives from System.Object , so you can put a struct in a Hashtable :
myTot tot = new myTot();
tot.strDesc = "blah";
tot.fTots = new double[] {1.2, 3.4};
Hashtable t = new Hashtable();
t["key1"] = tot;
Console.WriteLine(((myTot)t["key1"]).strDesc); Read the documentation for the classes in System.Collections about enumerations, collections, lists, and dictionaries. For instance, to enumerate through all the values of a dictionary using the keys, you could do the following:
IEnumerator e = t.Keys.GetEnumerator();
while (e.MoveNext())
{
Console.WriteLine("{0}: {1}", e.Current, t[e.Current]);
} You could also use the foreach keyword for a shortcut:
foreach (object key in t.Keys)
{
Console.WriteLine("{0}: {1}", key, t[key]);
}
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
I have a windows form application that i'd like to be able to send startup parameters to tell it what settings file to load say:
myApp.exe /settings.xml
how would a do this?
|
|
|
|
|
There are two ways:
1. You receive the startup parameters through an array of string objects passed into the static Main() method.
2. You can access the startup paramters from anywhere in your application using Environment.CommandLine property (this will give you the whole command line as one string) or the Environment.GetCommandLineArgs() method which will split the command line up into its component arguments. See MSDN for more details on how to use these methods/properties.
I hope this helps,
Colin.
--Colin Mackay--
EuroCPian Spring 2004 Get Together[^]
|
|
|
|
|
Colin's right about command-line parameters, but if you want to pass settings specifically, you should use a .config file (in the form, yourappname.exe.config) and use either the <appSettings> section or make your own using IConfigurationSectionHandler . Use that as a keyword to search the CodeProject articles for a slew of examples. This is a better way since if is directly supported by the CLR and the class library, as well as maintains all settings for an application (even ones that you're application doesn't use directly, like assembly bindings) in one file.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
|
That's the first one that came to mind! I just thought a search would pull up some alternatives that may provide some other ways of doing things or specific examples he might be interested in.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
I have not hardly cut my teeth on RegEx yet. What I am trying to figure out is a way to replace line feeds with < BR >'s but not between of < PRE > and < /PRE > tags. Any easy answer to do with with RegEx?
Rocky <><
www.HintsAndTips.com
|
|
|
|
|
This is possible using regex with a multi-line expression, but if you're working with HTML you probably shouldn't do this. What if an element spans multiple lines and you replace the new line with <BR> ? You cause HTML errors that browsers will choke on. Putting breaks after inline images would also be bad, since it would screw up the flow of the image with the paragraph that surrounds it. There are several other cases where this would be bad, too.
To better help you solve this problem, let me ask why you want to do this? If you're generating the HTML files, it would be better to do this in the first place, or if you want to modify the files you should use a good HTML reader (unfortunately there isn't a specific reader in the base class library for HTML, though there is the HtmlTextWriter ).
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
I have text input via a multipe line TextBox and onces I Server.HTMLEncode it, I need to add the <BR>s for linefeeds. In a specially flagged section though I will be using a < Pre > tag and it requires linefeeds instead of the <BR>s. There are no HTML tags in any of the text entered, just a special tag which I will replace with < Pre > section.
This is for my HintsAndTips.com site that I will FINALLY be launching tonight (and hopefully, people will like posting tips to share since there are only a couple at the moment ). When they post their tips I have to have a special section for things such as code that you do not want text wraping and handle this through a special tag people can use to enclose that section. It is replaced with a scrollable div and a pre tag (to be more compatible with old IEs or would just use the "white-space" css feature).
At the moment I have it replacing all the linefeeds with <BR>s and they look okay in the browser, but the < Pre > does not handle blank lines and stacks the lines on top of each other.
I will be providing a better method of composing tips in the near future, but just needed something to allow people to display text that is much wider then the area provided and a scrollable div works great for that. Kind of like on CP when someone does not format an article good and it takes three monitors to view it horizonally Did not want that happening
Here is an example of tip with the Pre section I was referring to:
http://www.hintsandtips.com/hat.aspx?P=ShowTip&C=31&T=10[^]
Please excuse the home page at the moment, it will be created later tonight
Rocky <><
www.HintsAndTips.com
|
|
|
|
|
I'm teaching myself C# at present and I have hit a wall!
I need to be able to locate a specific string within a file (not a text file, an excel file) and replace it with another. The two strings may not be the same length.
I can open the filestream and open a binaryreader on it but am stuck from there.
Does anyone have any suggestions, or better still some example code I can learn from??
Many thanks, in advance,
Chris
|
|
|
|
|
cgcrute wrote:
I can open the filestream and open a binaryreader on it but am stuck from there.
What is your code? So we can better help you.
Mazy
No sig. available now.
|
|
|
|