FileSystemWatcher returns changed files in lower case
Hi,
The FileSystemWatcher works fine to return the files
changed. However, the path returned through
FileSystenArgs.FullName is always in lower cases, e.g.,
c:\projectfiles\watched\foo.txt even though both the
directory and file names are in proper case like
c:\ProjectFiles\Watched\Foo.txt.
I've tried to instantiate a DirectoryInfo or FileInfo
with the returned file path, hoping they will return the
path in proper case but without success. Is there a work
around? The project I'm working on copies the changes to
another machine so it's important that I can maintain the
case so users won't get confused.
Thanks in advance,
Donald Xie Tag: when will MS release Framework 2.0? Tag: 54057
Please help us... POSTing with Http/WebRequest
I have noticed that a lot of people were having a similar problem to mine
which involves using the POST method with the
HttpWebRequest/WebRequest/WebClient classes (.NET 1.1). The classes will
send out one HTTP packet that says content of a certain length will follow
but the second packet is never sent, which usually results in a 400 error
from the server. I've tried my code on both HTTP 1.0 and 1.1 servers and
both gave the same result. Here is my example:
Try
Dim LogInURL As String = "http://s2.starkingdoms.com/scripts/main.cgi"
'Dim LogInURL As String =
"http://sklone.homeip.net/scripts/BrowserLogin.aspx"
Dim Account As String = "blah"
Dim Password As String = "blah"
Dim Request As Net.HttpWebRequest = Net.HttpWebRequest.Create(LogInURL)
Request.ContentType = "application/x-www-form-urlencoded"
Request.Method = "POST"
Request.ProtocolVersion = Net.HttpVersion.Version10
'Request.ProtocolVersion = Net.HttpVersion.Version11
Dim RequsetStream As IO.Stream = Request.GetRequestStream()
Dim ASCIIEncoding As New System.Text.ASCIIEncoding
Dim PostData As Byte() = ASCIIEncoding.GetBytes("Account=" & Account &
"Password=" & Password)
RequsetStream.Write(PostData, 0, PostData.Length)
RequsetStream.Close()
Dim Reader As New
IO.StreamReader(Request.GetResponse().GetResponseStream())
Dim ResultHTML As String = Reader.ReadToEnd()
Reader.Close()
MsgBox(ResultHTML)
Catch ex As Exception
MsgBox(ex.Message)
End Try
And here's what happens:
POST /scripts/main.cgi HTTP/1.0
Content-Length: 25
Connection: Keep-Alive
Host: s2.starkingdoms.com
Followed by the Bad Request (400) error. Tag: when will MS release Framework 2.0? Tag: 54054
Properties the .NET IDE way?
All,
Anybody know if there is an easy way to duplicate how the .NET IDE
presents properties and events? Specifically that it has a window with a
Name/Value pair but the value field is editable and can contain a drop-down,
combo, edit box, multi-line edit box, etc?
Erin. Tag: when will MS release Framework 2.0? Tag: 54052
Multiple frameWorks, Serialization and Versions
Hi
I got some type of form designer where I could open up
a .net form (done with reflection in run time so I'm
not using design time environment or anything) move
controls around and finally save the form. What it really
saves is an xml file where controls properties are binary
serialized. Next time I open up the form I could just load
this this xml file deserialize properties and assign them
to corresponding objects. Now the problem is the controls
that I have are the custom controls inherited from dotnet
ones, and we have a total build process that runs everyday
and changes versions of these controls. So we are using
simple binary serialization (doesn't include versions).
This is fine if you don't have another version of .net
framework in gac. What would you suggest here? Tag: when will MS release Framework 2.0? Tag: 54043
Socket.Select Bug??
There seems to be a 64 element limit on any socket list
passed as a argument to the select method.
Someone else in the forum traced the IL code, and found
some problems in the following code, I don't know if it is
a bug.
In this method , it first stored the count of the
socketlist we passed in with out any range check,
and then if the count isn't zero, the method will always
allocate a native int[64] array, which ofcourse doesn't
match with the value in FileDescriptorSet.Count, then the
IndexOutOfRangeException is thrown in the following codes.
maybe the conceptual code in c# like this:
FileDescriptorSet(Int32 count) {
Count = count;
if (!Count)
Array = new IntPtr(64);
else Array = null;
}
System.Net.Sockets.FileDescriptorSet
..method public hidebysig specialname rtspecialname
instance void .ctor(int32 count) cil managed
{
// Code size 27 (0x1b)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldarg.1
IL_0002: stfld int32
System.Net.Sockets.FileDescriptorSet::Count
IL_0007: ldarg.0
IL_0008: ldarg.1
IL_0009: brfalse.s IL_0014
IL_000b: ldc.i4.s 64
IL_000d: newarr [mscorlib]System.IntPtr
IL_0012: br.s IL_0015
IL_0014: ldnull
IL_0015: stfld native int[]
System.Net.Sockets.FileDescriptorSet::Array
IL_001a: ret
} // end of method FileDescriptorSet::.ctor
Any comments are welcome. Tag: when will MS release Framework 2.0? Tag: 54034
Upgrade .NET Framework
Hello All,
I was trying to use FolderBrowserDialog dialog box that
is supported only in version 1.1 of .NET Framework. So I
upgraded the .NET framework from 1.0 to 1.1 by
downloading the dotnetfx.exe. Everything went well with
Upgrading but still .NET didn't recognize
FolderBrowserDialog type and when I checked the
version .NET Framework in "About Microsoft Visual
Basic .NET" it showed the version is still 1.0.
Any idea about this issue? Or do you know any other way
rather than using the FolderBrowserDialog in VB?
I appreciate your help in advance. Tag: when will MS release Framework 2.0? Tag: 54033
HttpWebRequest
I am very frustrated trying to use .NET's HttpWebRequest. Does anybody know
where I can find "GOOD" HttpWebRequest documentation and samples? The
microsoft ones are woefully inadequate and my last few posts have gone
unanswered. You can check my earlier posts if you'd like to see the areas I
am having problems with.
Erin. Tag: when will MS release Framework 2.0? Tag: 54031
The argument type System.Data.DataSet cannot be converted into parameter type Sy
I have a three tier application using remote objects.
Everything works fine in my development environment but
when I move the code to production, I get the following
error when passing a dataset as a parameter.
The argument type System.Data.DataSet cannot be converted
into parameter type System.Data.DataSet Tag: when will MS release Framework 2.0? Tag: 54029
Windows Communication & Application Instancing in DotNet
Good Morning,
My problem is 2 fold. First of all, I want to find out a method of detecting
whether a prev. instance of an application is already running (I think I
already figured this out), and if so, send a message to that already running
application (I am thinking by using the WIN32 API Call of "SendMessage").
I am trying to build an application within which I could do
instancing/hooking. Basically, I want to be able to build an application
that would be able to detect if another instance of it is already running,
and if so, communicate with that already running instance, and send a
command, and shut its self down. Almost the same behavior that outlook
express has... i.e. if you already have outlook express already running and
you attempt to lunch the executable again... it doesn't create a new
instance of outlook.
I currently have a function called PrevInstance() that detects whether or
not a prev. instance of the same app is already running.. My only problem
now is communicating with that already running instance of my application.
Public Function PrevInstance() As Boolean
If
UBound(Diagnostics.Process.GetProcessesByName(Diagnostics.Process.GetCurrent
Process.ProcessName)) > 0 Then
Return True
Else
Return False
End If
End Function
--
Awah Teh
DigicentriQ Technologies, LLC
awaht@digicentriq.com
www.digicentriq.com
877 675 4742
805 732 9421
--
Awah Teh
Chief Executive Officer
DigicentriQ Technologies, LLC
awaht@digicentriq.com
www.digicentriq.com
877 675 4742
805 732 9421 Tag: when will MS release Framework 2.0? Tag: 54027
accessing to a windows service
hi all!
i've created a windows service written on c#. i've added some methods into
the "main" class inherited from System.ServiceProcess.ServiceBase. is there
any way to get an access to them from any other .net application? when i try
to add a reference using the service's exe file as a source, i get a message
like "a reference to '...' could not be added. this is not valid assembly or
COM component. only assemblies with extention 'dll' and COM components can
be referenced.", etc.
so how can i get an access to the methods and properties of my service from
other .net applications?
thanks.
---
mr.black's here... Tag: when will MS release Framework 2.0? Tag: 54026
Bringing back previous instance
I can prevent my application to exist in more than one instance by using Mutex. I want the previous instance back to desktop when
the user wanna open the second instance. Can I use mutex name to get the form of the prevous instance? I don't want to use the name
of the form. Thanks.
--
My C++ and C# ( Traditional Chinese ) Web Site : www.franzwong.com Tag: when will MS release Framework 2.0? Tag: 54025
Connection delay after upgrade to .NET 1.1
When making a socket connection to a server from a client
using the new .NET Framework version 1.1 in a Web
Application, we are getting a severe delay in the granting
of the socket connection. We did not get this using the
previous version of .NET (1.0...). The delay is between 1
and several minutes long. Finally, after the delay, the
socket connection is made with no abnormal messages.
Then, as long as that IE remains up, we can dis-connect
and re-connect as many times as we want with no delays at
all.
Any and all comments would be greatly appreciated. Tag: when will MS release Framework 2.0? Tag: 54020
Getting Started on .NET
I have an experience of more than 2 yrs on VB6.0 &
ASP2.0. I would like to know how do I get myself started
on the .NET platform. Are there any books that I may need
to refer? Also, do I need to learn all the three
languages- C#, ASP.NET & VB.NET right away? Tag: when will MS release Framework 2.0? Tag: 54018
HttpWebRequest, transfer-encoding?
I need to post some data to a server. As I understand it (which is not to
say I do understand it) I should be able to include a "transfer-encoding:"
header of say- gzip, then gzip my content before posting. Since it is a
transfer-encoding, I assume any half decent web server should be able to
automatically ungzip it before passing it on to whatever app needs to handle
it.
Is this assumption correct? If so, does .NET support gzip transfer encoding
or do I need an external library, program, etc.
If external is necessary, where should I look.
Regards,
Erin
-=Universal Subscriber=- Tag: when will MS release Framework 2.0? Tag: 54013
Why does Microsoft have such a hard time understanding what they say?
You know there is a difference between the Microsoft .NET Framework and the
Microsoft .NET Framework SDK. Besides the fact that the former is 20 some
MB and the latter is some 100MB there is a difference you know. But not
according to this page:
http://support.microsoft.com/?scid=kb;en-us;306160
This command near the bottom:
N:\dotnetframework\dotnetfx.exe /t:c:\temp /c:"msiexec.exe /i
c:\temp\netfx.msi REINSTALL=ALL ReinstallMODE=vomus"
has not a damn thing to do with the Microsoft .NET Framework SDK. This is a
reinstallation of the Microsoft .NET Framework which is NOT the Microsoft
.NET Framework SDK as the title of this article says.
To me this is like the misunderstanding of Microsoft Outlook and Microsoft
Outlook Express.
Why does Microsoft have such a hard time understanding what they say? And
finally is there a repair for the Microsoft .NET Framework SDK not to be
confused with the Microsoft .NET Framework? Thanks.
--
George Hester
__________________________________ Tag: when will MS release Framework 2.0? Tag: 54012
.Net Framework and Sharepoint Server
I was just wondering if .Net Framework would interfere with stuff in a
Sharepoint Server? Because in our IIS server, we are getting a 404 on
a smart client app that we are trying to deploy. We tried 3 other IIS
servers (development), and it seemed to work. It is just that one
server (Release) which gives us a 404. Any Ideas?
Thanks. Tag: when will MS release Framework 2.0? Tag: 54011
HRESULT 80004005
Event Type: Error
Event Source: ASP.NET 1.0.3705.0
Event Category: None
Event ID: 1082
Date: 8/11/2003
Time: 9:50:10 AM
User: N/A
Computer: MyComputer
Description:
aspnet_wp.exe could not be started. HRESULT for the failure: 80004005
The .NET Framework has been just fine for months. I tried installing and
using one of the Fabrikam Office XP solutions. They worked (didn't
actually) poorly and so tried to remove them. Now this is the condition of
my Framework. I've tried uninstalling and reinstalling and uninstalling and
reinstalling and uninstalling and reinstalling and uninstalling and
reinstalling and uninstalling and reinstalling and uninstalling and
reinstalling and uninstalling and reinstalling and uninstalling and
reinstalling and uninstalling and reinstalling and uninstalling and
reinstalling and uninstalling and reinstalling and uninstalling and
reinstalling and uninstalling and reinstalling and uninstalling and
reinstalling and no go.
Any ideas?
http://support.microsoft.com/default.aspx?scid=kb;en-us;306518
--
George Hester
__________________________________ Tag: when will MS release Framework 2.0? Tag: 54006
Screen capture?
Under VB6, it was fairly straightforward to get a
screenshot. For instance, the following code:
Public Function ScreenshotBits(hWnd As Long, Optional
compress As Boolean = True) As Byte()
Dim bitmap_info As BITMAPINFO
Dim pixels() As Byte
Dim Size As Long
Dim dc As Long
dc = GetDC(hWnd)
Dim memDC As Long
memDC = CreateCompatibleDC(dc)
Dim r As RECT
GetClientRect hWnd, r
' Prepare the bitmap description.
With bitmap_info.bmiHeader
.biSize = 40
.biWidth = r.Right - r.Left
' Use negative height to scan top-down.
.biHeight = r.Top - r.Bottom
.biPlanes = 1
.biBitCount = 32
.biCompression = BI_RGB
End With
Dim bm As Long
Dim ptr As Long
bm = CreateDIBSection(dc, bitmap_info, DIB_PAL_COLORS,
ptr, 0, 0)
Dim oldbm As Long
oldbm = SelectObject(memDC, bm)
BitBlt memDC, 0, 0, r.Right - r.Left, r.Bottom -
r.Top, dc, 0, 0, SRCCOPY
' Copy the bitmap's data.
Size = (r.Right - r.Left) * (r.Bottom - r.Top) * 4
ReDim pixels(0 To Size - 1)
GetDIBits dc, bm, 0, r.Bottom - r.Top, pixels(0),
bitmap_info, DIB_PAL_COLORS
If compress Then
Dim z As New clsZLib
z.CompressByte pixels
End If
SelectObject memDC, oldbm
DeleteObject memDC
DeleteObject bm
ScreenshotBits = pixels
End Function
How do I duplicate this functionality in VB.NET? That is,
I could import all the API calls and do almost the exact
same code, but the .NET framwork abstracts tons of things
that were previously the realm of API calls. Is there
a .NET way to do this?
~BenDilts( void ); Tag: when will MS release Framework 2.0? Tag: 54003
MDI + KEY DOWN EVEN problem
Hi,
I am working with MDI form in .NET, In a child form i am unable to move the
cursor to previous control using the Shift + Tab combination in Keycode
Event procedure. Even i set the tabStop property to false for all controls.
It is working fine when it shows as a normal form (Non MDI). The problem
occurded only when it shows as a MDI child.
Kindly let me the problem
Regards,
GOVIND. Tag: when will MS release Framework 2.0? Tag: 53992
How do I write to a private folder?
Hi all,
I am trying to write a stand alone C# Console program with .NET framework.
The program will create a folder in a existing folder. The existing folder
is set with "Make this folder private" and "Encrypt contents to secure
data". I tried LogonUser, Impersonate, AddPermission to PermissionSet but
none of them work. The error is "Access to ... is denied" eventhough I run
the program in the same account that I used to create the folder. I dont
have any problem to create to any other folders without the private and
encrypt setting. I am using Windows XP, NTFS and the existing folder is
created in user profile directory.
Please help.
TIA
Hung Nguyen Tag: when will MS release Framework 2.0? Tag: 53989
documents of MSIL & CLR?
Hi,
I am a C# developer and want to study deeply about the .NET internals, MSIL
and CLR. Where can I find reference documents about them? For example,
reference to all operation instructions of intermediate language, and file
organization of a .NET assembler. I believe there should be documents about
those areas, but could not find them in my MSDN Library(July 2k3)
Very thanks,
weixiang Tag: when will MS release Framework 2.0? Tag: 53981
"Automation server cannot create Object"
Hi,
I get a error when i open or create a new project in .Net.
"Automation server Cannot create Object".
What's the reason and how do i rectify it.
Thanks
Jayant Tag: when will MS release Framework 2.0? Tag: 53977
Multiple Debugging sessions
Hi,
I was wondering if it is possible to have multiple
debugging sessions? When I try to have someone else run
another session I get an error message:
Error while trying to run project: Unable to start
debugging on the web server. A debugger is already
attached. Would you like to disable future attempts to
debug ASP.NET pages for this project?
We are running .dot framework version 1 and using Visual
Studio 2002.
Has anyone got any ideas or done this.
Cheers,
Russell Tag: when will MS release Framework 2.0? Tag: 53974
reflection - discover control's properties.
Hi.
I would like to be able to iterate recursively through a
web page, and for every control on the page, chech if it
has "CssClass" property and to be able to change it.
How can this be done?
Thanks
Roy Tag: when will MS release Framework 2.0? Tag: 53971
JIT
For those of you coding windows Application under the framework you must
noticed that forms take a performance hit loading the first time. This is
because of JIT, I was able to fix this behavior by using ngen.exe, but then
I don't get the same optimization JIT gives me and it is a headache for
installations (negen has to be called right after the installation).
According to Microsoft, a function gets JIT to native code the first time it
is accessed. Is it possible to tell the framework to JIT certain functions
at runtime without actually calling the functions?
Basically, I would like to pre-JIT some of my functions so they don't
experience a performance hit the first time they are called.
Is this possible? Tag: when will MS release Framework 2.0? Tag: 53963
GetLastError
Hi,
I'm quite new to the .net framework and try to port some old code to csharp.
In my code I have a call to a Win32 API function which returns error
information by setting the last Win32 error code. I found a
GetLastWin32Error() in the Marshal class which seems to do what
GetLastError() did.
Can anyone tell me how to get a string from the returned error code?
In Win32 API code I used FormatMessage(), in Delphi SysErrorMessage().
Anything similar in the .net class library?
thanks,
Nick Tag: when will MS release Framework 2.0? Tag: 53962
Installation of Visual Studio Addin
Hello,
I'm actually trying to develop an ASP Parser addin for
Visual Studio, and have some problem deploying it.
When i try to deploy it on a machine where i didn't
compile the project the addin fails to load when visual
studio loads. There is an error and it proposes to
uninstall the addin.
When i scanned the registry while compiling or installing
i remarked that the registry was modified only at compil
time. So perhaps these registry settings(COM settings),
are missing on target machine.
Any idea, anyone? Tag: when will MS release Framework 2.0? Tag: 53961
Hosting as assembly in IE
Hi,
It is said that an assembly host can be 1.Shell, 2. ASP.NET(IIS) and
3.IE brower.
I'm familiar with 1 and 2. Can sb tell me HOW TO.., for case 3 with
possibly few examples ?
TIA
Kishore Tag: when will MS release Framework 2.0? Tag: 53959
sockets and proxy Settings
Hi,
I am writing a client in C# which uses the system.net.sockets namespace and
the scoket class to connect toa remote server.
I would like this client to work on machines that use a proxy server to
connect to the internet.
How do i advice the socket about what proxy settings to use?
Thanks/Regards
Sanket Gupta
Sanket Gupta F-26/112/7 Rohini Delhi-110085 India sanket@tsucorp.net tel:
mobile: 91-11-27931935 91-9810197671 Powered by Plaxo Want a signature like
this? Tag: when will MS release Framework 2.0? Tag: 53957
HttpWebRequest question
All,
How can I determine at runtime if a URL I'm going to requires a client
cert. The only thing I am able to get is the 403 Forbidden?
Erin Tag: when will MS release Framework 2.0? Tag: 53955
ICertificatePolicy question.
All,
I've implemented a class that inherits the ICertificatePolicy interface. I
then set ServicePointManager.CertificatePolicy = this. In my
CheckValidationResult(), I log server cert info and return true. Now say for
example, the CN name on the server cert does not match the site name, my
CheckValidationResult() function is called. After returning true, if I go to
the same site- my CheckValidationResult() is not called again. I assume
because I returned true, and it has cached that information.
My question is can I change this behavior so it will always call my
CheckValidationResult() on each new request, if there is a cert problem?
I've checked ServicePointManger and ServicePoint but do not see any method
that would clear, flush, reset, etc. this information.
Regards
Erin. Tag: when will MS release Framework 2.0? Tag: 53954
XML Text Reader/Writer and Boolean
When I write out a boolean with the text writer, it
writes out 'False'. When I try and read it in, using
XmlConvert.ToBoolean, it errors out because it is
expecting 'false' (all lower case). Is this a known bug?
Thanks Tag: when will MS release Framework 2.0? Tag: 53950
asp.net on xp home
Hi,
I want to install and learn the ASP.Net starter kits. I have Windows XP
machine and Visual Studio 2002. Is it possible?
Thanks... Tag: when will MS release Framework 2.0? Tag: 53948
Use Class Library in Unmanaged Code
I have created a class library by C#. Then I want to use it in MFC / Win32 program.
This is my class
public interface IShowDialog
{
string Caption
{
set;
}
void ShowDialogOut();
}
public class ShowDialog : IShowDialog
{
private string _strCaption;
public ShowDialog()
{
}
public string Caption
{
set { _strCaption = value; }
}
public void ShowDialogOut()
{
System.Windows.Forms.MessageBox.Show(_strCaption);
}
}
The following is the code in the client.
ATL::CComPtr<ShowDialogLib::IShowDialog> pShowDialog;
HRESULT hr = pShowDialog.CoCreateInstance(L"ShowDialogLib.ShowDialog");
if (FAILED(hr))
AfxMessageBox("Error in Loading ShowDialogLib.dll");
else {
pShowDialog->put_Caption(L"Hello World");
pShowDialog->ShowDialogOut();
pShowDialog.Release();
}
My question is when I use pShowDialog->put_Caption(L"Hello World"), the message box will show nothing.
But if I use
CString str = "Hello World";
pShowDialog->put_Caption(str.AllocSysString());
The message box can show the text "Hello World".
I want to know why does it behave like that?
--
My C++ and C# ( Traditional Chinese ) Web Site : www.franzwong.com Tag: when will MS release Framework 2.0? Tag: 53945
programming under version1 and running under version 1.1 or 2
if I code using Visual Studio (2002) using framework v1.0
then upload to my host server that is running version2 of
the framework could I expect any problems in running the
application or would it work OK
John Tag: when will MS release Framework 2.0? Tag: 53944
UML for .NET developers
There are some great free tutorials for .NET developers on UML at
http://www.objectmonkey.com, plus loads of other useful free tutorials
and papers on everything from Test-driven Development to UI design
patterns. Tag: when will MS release Framework 2.0? Tag: 53938
Ways to create ADOBE PDF files on-the-fly
Hello Folks,
To the point at hand:
Does the DotNetFramework library have a function to allow my
program to create ADOBE Pdf files without using interop?
What are the things I need to create PDF files in DotNet?
Thanks a many!
Anonieko Tag: when will MS release Framework 2.0? Tag: 53908
Event and Delegate
Hello, i am just a newbie!
i don't understand the statement
theClock.OnSecondChange += new Clock.SecondChangeHandler
(TimeHasChanged);
what is the statement doing ?
And also, why should we "subscribe" "dc" and "lct" before
running the clock?
THANKS!
namespace Programming_CSharp
{
using System;
using System.Threading;
// a class to hold the information about the event
// in this case it will hold only information
// available in the clock class, but could hold
// additional state information
public class TimeInfoEventArgs : EventArgs
{
public TimeInfoEventArgs(int hour, int
minute, int second)
{
this.hour = hour;
this.minute = minute;
this.second = second;
}
public readonly int hour;
public readonly int minute;
public readonly int second;
}
// our subject -- it is this class that other
classes
// will observe. This class publishes one event:
// OnSecondChange. The observers subscribe to that
event
public class Clock
{
// the delegate the subscribers must
implement
public delegate void SecondChangeHandler
(
object clock,
TimeInfoEventArgs timeInformation
);
// the event we publish
public event SecondChangeHandler
OnSecondChange;
// set the clock running
// it will raise an event for each new
second
public void Run( )
{
for(;;)
{
// sleep 10 milliseconds
Thread.Sleep(10);
// get the current time
System.DateTime dt = System.DateTime.Now;
// if the second has
changed
// notify the subscribers
if (dt.Second != second)
{
// create the
TimeInfoEventArgs object
// to pass to the
subscriber
TimeInfoEventArgs
timeInformation =
new
TimeInfoEventArgs(
dt.Hour,dt.Minute,dt.Second);
// if anyone has
subscribed, notify them
if
(OnSecondChange != null)
{
OnSecondChange(
this,timeInformation);
}
}
// update the state
this.second = dt.Second;
this.minute = dt.Minute;
this.hour = dt.Hour;
}
}
private int hour;
private int minute;
private int second;
}
// an observer. DisplayClock subscribes to the
// clock's events. The job of DisplayClock is
// to display the current time
public class DisplayClock
{
// given a clock, subscribe to
// its SecondChangeHandler event
public void Subscribe(Clock theClock)
{
theClock.OnSecondChange +=
new
Clock.SecondChangeHandler(TimeHasChanged);
}
// the method that implements the
// delegated functionality
public void TimeHasChanged(
object theClock, TimeInfoEventArgs
ti)
{
Console.WriteLine("Current Time:
{0}:{1}:{2}",
ti.hour.ToString( ),
ti.minute.ToString( ),
ti.second.ToString( ));
}
}
// a second subscriber whose job is to write to a
file
public class LogCurrentTime
{
public void Subscribe(Clock theClock)
{
theClock.OnSecondChange +=
new Clock.SecondChangeHandler(WriteLogEntry);
}
// this method should write to a file
// we write to the console to see the
effect
// this object keeps no state
public void WriteLogEntry(
object theClock, TimeInfoEventArgs
ti)
{
Console.WriteLine("Logging to
file: {0}:{1}:{2}",
ti.hour.ToString( ),
ti.minute.ToString( ),
ti.second.ToString( ));
}
}
public class Test
{
public static void Main( )
{
// create a new clock
Clock theClock = new Clock( );
// create the display and tell it
to
// subscribe to the clock just
created
DisplayClock dc = new DisplayClock
( );
dc.Subscribe(theClock);
// create a Log object and tell it
// to subscribe to the clock
LogCurrentTime lct = new
LogCurrentTime( );
lct.Subscribe(theClock);
// Get the clock started
theClock.Run( );
}
}
} Tag: when will MS release Framework 2.0? Tag: 53898
How to determine if a port is already in use
Hi
I am modifying the Cassini web server to work with my
application.
I want it to be possible to pick a port and test it to
see if its already in use. If it is then I want to choose
the next port, test it and so on...
Can anyone tell me how to test a port to see if its
already in use.
Thanks, Paul. Tag: when will MS release Framework 2.0? Tag: 53892
.NET Framework Path
Hello all,
Just a quick question... Is it true that the path of the .NET framework
SDK files is always under:
{windir}\Microsoft.NET\Framework\{version}
? I.e. is there anyway the user could change this path?
I'm asking this because I am currently creating an IDE for .NET
programming and wanted to know the path for csc.exe, vbc.exe, ilasm.exe,
etc... If the path is variable, then I will get the user to choose it from a
dialog.
Thanks for your help,
Aaron Chan Tag: when will MS release Framework 2.0? Tag: 53890
=?iso-8859-1?Q?SetTabPicture_'Catastrophic_error'.?=
Hi,
I am writing a VS.NET Add-in, this Add-in is written
using C#(for the GUI) and C++, the Add-in includes a tool
window ( e.g. .Windows.CreateToolWindow ), I am trying to
set the windows tab image using
the '.LinkedWindowFrame.SetTabPicture' API, but I keep
getting a 'Catastrophic error' exception, what am I doing
wrong???
The C# GUI hosts a C++ ActiveX Control, the IPictureDisp
object is being created by the ActiveX Control and passed
to the C# GUI for future usage, the C# container uses
this Object to set the tab image of the wingdow ( e.g.
SetTabPicture)
Following is a simplified corresponding code sample:
C++:
#######################################################
ATL::CComPtr<IPictureDisp> spPicture;
PICTDESC ptd = { 0 };
HMODULE hEXE = LoadLibrary("C:\\windows\\regedit.exe");
ptd.cbSizeofstruct = sizeof(ptd);
ptd.picType = PICTYPE_ICON;
ptd.icon.hicon = (HICON)LoadImage(hEXE,
MAKEINTRESOURCE(100),
IMAGE_ICON,
16,
16,
LR_DEFAULTCOLOR);
::OleCreatePictureIndirect(&ptd,
__uuidof(IPictureDisp),
TRUE,
(void**)&spPicture);
FreeLibrary(hEXE);
Fire_OnPictureLoaded(spPicture)
C#:
#######################################################
private static void OnPictureLoaded(
stdole.IPictureDisp pIPictureDisp)
{
.bal bla bla.
try
{
// The following line generates the Catastrophic error
g_This.m_ToolWindow.LinkedWindowFrame.SetTabPicture(
pIPictureDisp);
}
catch(Exception exp)
{
System.Windows.Forms.MessageBox.Show(exp.Message);
}
}
WHY DO I GET A CATASTROPHIC ERROR ???
Thanks in advance,
Nadav,
Sofin l.t.d.
Look at a great new tool I have developed at:
http://www.ddevel.com/home/main.asp Tag: when will MS release Framework 2.0? Tag: 53885
How can I get motherboard Serial number?
I want to get motherboard serial number to protect copyright in my software.
But I don't know how to do.
I got some code from Internet:
Imports System.Management
Dim searcher As New ManagementObjectSearcher("SELECT * FROM
Win32_BaseBoard")
Dim share As ManagementObject
For Each share In searcher.Get()
Debug.WriteLine("manufacturer:" & share("Manufacturer"))
Debug.WriteLine("Product:" & share("Product"))
Debug.WriteLine("SerialNumber:" & share("SerialNumber"))
Next share
but it only return "Product" item, the other two is null.
How can I get unique MotherBoard Serial Number?
Waiting help.....!!!! Tag: when will MS release Framework 2.0? Tag: 53876
bug !!bug !! on windows synchronization!!
hi all, I have some problem on a Windows application in .Net Framework,just
as below:
private void button1_Click(object sender, System.EventArgs e)
{
WindowsApplication1.localhost.Service1 ser=new
WindowsApplication1.localhost.Service1();
textBox1.Text=ser.Add(int.Parse(textBox1.Text),1).ToString();
MessageBox.Show("ok");
}
you know, A webservice named ser is called in the above function,and ,when
the main form is loaded for the first time,if I click the button1 on the
form very quickly,the awful thing would happen:a messagebox is showed,when I
close it ,another messagebox is opened,I continue closing, and the same
thing happen:a messagebox is showed.The number of messageboxes is according
to the speed of my mouse clicking.
so, it seems the button1 still accept the click event while a webservice is
being called for the first time.But I expect only one messagebox would be
showed even though I click very quickly.How to control? hope your help!!!
Thank you! Tag: when will MS release Framework 2.0? Tag: 53872
Regular expressions and HTML
Hi
I'm working on a method that will transform an HTML fragment into an
XHTML fragment. I thought I'd have a go at using regular expressions
in .NET, because I don't really understand the numerous regular
expression classes in .NET and I thought it might be a good
opportunity to learn.
I want to break down the HTML into element names, attribute names,
attribute values and element content. The regular expression I came up
with, that successfully matches fragments such as <div contenteditable
id="test">, looks like this:
^(?<precedingText>[^<>]*)((((<(?<elementName>[a-zA-Z_][a-zA-Z0-9_]*)\s*((?<=\s)(?<attributeName>[a-zA-Z_][a-zA-Z0-9_]*)((\s*=\s*""(?<attributeValue>[^""]*)""\s*)|(\s*=(?<attributeValue>[^\s"">]+)\s*)|(\s*(?!\s*=))))*\s*>))|(</(?<closingElementName>[a-zA-Z_][a-zA-Z0-9_]*)\s*>))(?<text>[^<>]*))*$
A bit complicated I know, but it works. However, now I don't know how
to extract the various elementName, attributeName etc. group values in
order to match them up. All seems a bit wild to me.
Can anyone tell me the best way to construct a regular expression in
order to produce the desired result? I suspect using constructs such
as (?<elementName>....)* doesn't work so well because of the repeat,
but how else could it be done?
Cheers, Wangchuk Tag: when will MS release Framework 2.0? Tag: 53863
Can I make a class from XML? Serialize?
Hi guys,
I need a way to dynamically change (or create) a custom class using an
external xml file. Can this be done at all? This is what the class looks
like:
Public Class MemberData
Private _EmailGUID As String
Private _Email As String
Private _FirstName As String
Private _LastName As String
Private _Title As String
Private _Company As String
Private _Address As String
Private _PostalCode As Integer
Private _City As String
Private _Phone As String
Private _Active As Integer
Private _RegDate As DateTime
Private _ChangeDate As DateTime
Public Sub New()
MyBase.New()
_EmailGUID = ""
_Email = ""
_FirstName = ""
_LastName = ""
_Title = ""
_Company = ""
_Address = ""
_PostalCode = 0
_City = ""
_Phone = ""
_Active = 0
_RegDate = Nothing
_ChangeDate = Nothing
_SoftBounces = 0
_HardBounces = 0
_GroupIDs = ""
End Sub
Public Property EmailGUID() As String
Get
Return _EmailGUID
End Get
Set(ByVal Value As String)
If ((Value Is Nothing) OrElse (Value.Length = 0)) Then
Throw New Exception("The email address identifier cannot be
empty")
End If
_EmailGUID = Value
End Set
End Property
Public Property Email() As String
Get
Return _Email
End Get
Set(ByVal Value As String)
If ((Value Is Nothing) OrElse (Value.Length = 0)) Then
Throw New Exception("The email address cannot be empty")
End If
_Email = Value
End Set
End Property
[...]
End Class
Thanks.
Regards Jonah Tag: when will MS release Framework 2.0? Tag: 53850
.NET 'Old' Resource access ?????
Hi,
I wonder... How one should use C# to access resource data
stored in an EXE (8086*) binary ??? ( VC6 .rc resource
data )?
Can the ResourceManager be used to extract this type of
data?
Any directions/samples/pointers will be appriciated.
Thanks in advance,
Nadav,
Sofin l.t.d.
Look at a great new tool I have developed at:
http://www.ddevel.com/home/main.asp Tag: when will MS release Framework 2.0? Tag: 53840
How to obtain invalid file name characters
Hi,
How does one obtain a platform's invalid file name characters from the
.NET framework? I have noticed that invalid path characters can be
obtained from System.IO.Path.InvalidPathChars but this list does not
include items that would be illegal for file names (for example, a
colon: would be invalid in a MS Windows environment).
Please note that catching an exception from Path.GetFileName() would
allow me to test the validity of a file name but would not allow me to
include the invalid characters in a message to the user.
Many thanks.
Nathan Tag: when will MS release Framework 2.0? Tag: 53833
Template Based Applications
I am about to start a new project, which a template based
application. It's a report generator (MS Word). The user
selects a report template and fills it with the report
specific information. It can't be ms word template
itself. The application is much more complicated than
that. Do you know of the papers/articles regarding the
template based application architecture and design? Tag: when will MS release Framework 2.0? Tag: 53832
Faulty implmentation of ThreadPool.RegisterWaitForSingleObject
I think I've found a problem in the framework implementation of the
ThreadPool RegisterWaitForSingleObject method. Given the following C# code:
static void Main(string[] args)
{
ManualResetEvent evt1 = new ManualResetEvent(false);
ManualResetEvent evt2 = new ManualResetEvent(false);
ThreadPool.RegisterWaitForSingleObject(evt1, new
WaitOrTimerCallback(EventProc), "Event 1", 30000, false);
ThreadPool.RegisterWaitForSingleObject(evt2, new
WaitOrTimerCallback(EventProc), "Event 2", 30000, false);
evt1.Set();
evt2.Set();
Thread.Sleep(20);
evt2.Reset();
evt1.Reset();
}
private static void EventProc(object state, bool timedOut)
{
Console.WriteLine(state);
}
I'd expect to see messages for both Event 1 and Event 2 during the time they
are both set. However, only messages from Event 1 show up. According to
the docs, the RegisterWaitForSingleObject method is implmented using the
Win32 WaitForMultipleObjects call to monitor all of the registered objects,
with the fWaitAll parameter set to false I'd assume. However in that case,
the WaitForMultipleObjects call only returns at most one indicator of a
signaled object even if more than one of the objects are signaled. That
means that when both evt1 and evt2 are signaled in the above code, the
program will only get notifications of the lowest indexed one in the
WaitForMultipleObjects handle array.
Obviously using manual event handles makes the problem stand out more, but
this could definitely cause problems if someone expects notifications no
matter how many other objects are signaled at the same time.
I beleive that the implementation should be corrected, or at least have the
framework documentation updated to point out this issue.
Jeff Skaistis Tag: when will MS release Framework 2.0? Tag: 53829
Who know the plan?
Where can I get the plan about .net development?