|
wickerman.26 wrote:
I've got the binary operators to evaluate my object as a DateTime value working just fine. My assignment operators are another story entirely - how do I create an assignment operator without having the other data in my object get reset to their default values (as happens below)?
You can't. It is like if you cast between an int and a byte. A byte can hold values 0 to 255, an int can hold values -2billion to +2billion (approx.)
byte myByte = 100;<br />
int myInt = (int)myByte;<br />
But if you do this:
int myInt = 1000;<br />
byte myByte = (byte)myInt;<br />
Actually the result is 232, which is the same as (myInt%256) . This is because to fit into an int the data had to be truncated, and if we try and reassign the byte back to the int, we will only ever see as much as was truncated.
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
The Second EuroCPian Event will be in Brussels on the 4th of September
Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!
|
|
|
|
|
Thanks, that's what I thought.
-- Carter
Seattle, WA
"In illusion comfort lies" - SoM
|
|
|
|
|
Can anyone point me to an example that seperates your Windows Form and it's events away from the class that actually carries out your Application logic?
|
|
|
|
|
CN78 wrote:
Can anyone point me to an example that seperates your Windows Form and it's events away from the class that actually carries out your Application logic?
Yes, create a new C# file, without any controls in it
top secret xacc-ide 0.0.1
|
|
|
|
|
Model-View-Controller Pattern[^]
This article describes the MVC pattern in relation to web pages, but many of the ideas also apply to Windows Forms.
From the above link:
The Model-View-Controller (MVC) pattern separates the modeling of the domain, the presentation, and the actions based on user input into three separate classes [Burbeck92]:
Model. The model manages the behavior and data of the application domain, responds to requests for information about its state (usually from the view), and responds to instructions to change state (usually from the controller).
View. The view manages the display of information.
Controller. The controller interprets the mouse and keyboard inputs from the user, informing the model and/or the view to change as appropriate.
Does this help?
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
The Second EuroCPian Event will be in Brussels on the 4th of September
Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!
|
|
|
|
|
I'm looking to read a text file that has properties coded on it ex : name=Joe
and can set a control with those properties at run time. Here is an example of what i've coded for this already :
private void ReadFile()
{
StreamReader sr;
string ;s
sr = File.OpenText("c:\\Test.txt");
s = sr.ReadLine();
sr.Close();
tabPage1.Text = s;
}
I need to start setting the numberOfTabs I want, the Alignment of the tabs.
|
|
|
|
|
Anonymous wrote:
private void ReadFile()
{
StreamReader sr;
string ;s
sr = File.OpenText("c:\\Test.txt");
s = sr.ReadLine();
sr.Close();
tabPage1.Text = s;
}
private Hashtable ReadFile(string filename)
{
string s;
Regex re = new Regex(@"^\s*(?<name>\w+)\s*=\s*(?<value>.+?)\s*$",
RegexOptions.ExplicitCapture);
Hashtable nv = new Hashtable();
StreamReader sr = File.OpenText(filename);
while ((s = sr.ReadLine()) != null)
{
Match m = re.Match(s);
if (m.Success)
{
nv.Add(m.Groups["name"].Value, m.Groups["value"].Value);
}
}
sr.Close();
return nv;
}
top secret xacc-ide 0.0.1
|
|
|
|
|
Sounds like what I use .ini files for.
I think there's a C# article on Code
Project that encapsulates WritePrivateProfileString
and ReadPrivateProfileString. Or you could
DLLImport them and roll your own.
Delphi has a pretty nice TIniFile class so
what I did was write a dual-interface COM
wrapper for it so I could use it with anything
that can use COM. I haven't tried it with
C# yet though. It worked fine with VB 6 and
VC++ 6.
|
|
|
|
|
Thanks for the replies, any other ways of doing this ?
|
|
|
|
|
It is kind of like any INI file, but you instead of initializing the component on startup, you are just setting its propeties. I realize this is not the best way to do this, however this is an exercise I must complete. Thanks for the replies, any other ways of doing this ?
|
|
|
|
|
|
No, there is no premade assembly that wraps GhostScript. Various people have built their own by P/Invoking the hell out of the GhostScript .DLL's, but I haven't seen any wrapper publicly available.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I have a dll with about 10 embedded images in it. I would like to pull these out and load them when an event is fired(not all at once )but which ever one is needed depending on the user selection.
My problem is I have absoulutly no clue how to go about this even after making the reference.
Also I don't know that the dll was built properly. I created a resource file and added all the pics to it ( paths) and opened a blank project and added the resource file and built the proj as a class lib.
Also I created an empty proj and added all images, changed their propertys to embeded types , and built the proj as a class lib.
Both files are the same size 236kb. Still I can not "Get" the images out of the darn dll.
Any help , links , answers would MORE than apprieciated !!!
Thanks in advance,
Billy
I wish I could help instead of asking for it !
Can I open that beer for you ?
|
|
|
|
|
You need to create a ResourceManager object and use it to pull the images from your assembly.
See this[^], this[^], and this[^] on MSDN.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Our scenario is:
Various business objects on server using interfaced-based remoting being called by a thick Windows client.
In some situations, instead of receiving a "normal" exception or one of our custom exceptions we receive the following:
"See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
System.IO.FileNotFoundException: File or assembly name Product, or one of its dependencies, was not found.
File name: "Product"
at System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Boolean isStringized, Evidence assemblySecurity, Boolean throwOnFileNotFound, Assembly locationHint, StackCrawlMark& stackMark)
at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Boolean stringized, Evidence assemblySecurity, StackCrawlMark& stackMark)
at System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark)
at System.Reflection.Assembly.Load(String assemblyString)
at System.Reflection.MemberInfoSerializationHolder..ctor(SerializationInfo info, StreamingContext context)
at System.Exception.GetExceptionMethodFromString()
at System.Exception.GetTargetSiteInternal()
at System.Exception.get_TargetSite()
at IDTEC.Components.Exceptions.IDTException.ToString()
at IDTec.UI.IDTecControls.IDTDialogBox.ShowErrorDialog(String showOnlyMessage, Exception e, String pluginName, String pluginVersion, String methodName)
at Rectron.Plugins.Side.btnNew_Click(Object sender, EventArgs e)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)"
I'm 100% percent sure that is not a missing dependancy - else nothing would ever work.
We have also been seeing this type of error from other assemblies.
Has anyone come across a situation where the DLL throws this error instead of a standard .NET exception?
EDIT:
I get a proper error while running in debug inside VS, but get the above error while running on our test machine.
Same build and same user, but different error...
Cheers,
Simon
sig :: "Don't try to be like Jackie. There is only one Jackie.... Study computers instead.", Jackie Chan on career choices.
article :: animation mechanics in SVG blog:: brokenkeyboards "It'll be a cold day in Hell when I do VB.NET...", Chris Maunder
|
|
|
|
|
Hello,
I've coded my own NumericTextBox. But there's a little feature I want to add: If you try to enter a character in the TextBox, this very typical sound should be played. But I don't know how I can do this.
|
|
|
|
|
If you've done this correctly and your already filtering out the incorrect key presses, you could just P/Invoke Beep in the Win32 API.
[DllImport("kernel32.dll", SetLastError=true)]
static extern bool Beep(uint dwFreq, uint dwDuration);
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi every body!
My company wants to write a chat program. There will be about 300 people using this program. I see that we can use remote object technology to write this program. But I don’t know whether I will have to face with any problem when I deploy this program, what is advantage, disadvantage of the technology.
Could you give me some opinion?
Should I use remote object or socket technology?
Thanks a lot!!
xyz
|
|
|
|
|
It really doesn't matter which one you use. For a chat program, it's just a matter of preference, neither is harder than the other to implement, IMHO...
Why would your company want to write a chat program for internal use, when there are tons of them on the market that would probably cost less, off the shelf, if not free in some implementations, than paying you by the hour to write it?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I am trying to pass an Int32 array from C# to C++ COM object but am getting E_UNEXPECTED error from SafeArrayAccessData(…) call.
From C# I pass 'ref object' where the object is my Int32 array, and my COM object receives it as a VARIANT*.
Thanks for any suggestions
|
|
|
|
|
Hi,
I am looking for a recommendion a good utility for creating typed collections in C#, preferably a plug in to VS.NET. Could you let me know if you know of any good utilities?
TIA
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
The Second EuroCPian Event will be in Brussels on the 4th of September
Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!
|
|
|
|
|
|
nice of you to share us the solution you found..
a small note :
in the .net framework 2.0 collections will be available as templates.So we'll have better performance since there will be no casting and boxing/unoxing.
|
|
|
|
|
hspc wrote:
nice of you to share us the solution you found
Your welcome. Actually, I'm still hoping for a recomendation because that one I mentioned is a little quirky. But the article itself is quite useful for a starter in to VS Add-ins.
hspc wrote:
in the .net framework 2.0 collections will be available as templates
Except that what everyone knows and loves as templates is called "generics" in .NET 2.0.
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
The Second EuroCPian Event will be in Brussels on the 4th of September
Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!
|
|
|
|
|
sorry, but i meant how to deploy an application.exe . there are tow application: the first application deals with some Xml files, but this files are them selves generated by a second application, so can i use this last one (second application) to generate the xml files (already done) and deploy the Firstapplication.exe that use the generated xml files and so create a firstapplication Setup.exe without using the setup wizard.
|
|
|
|