Suggestions for .Net CLR
A couple of suggestions for enhancing the .Net CLR:
Property indexers:
To be able to have an indexed property (as opposed to a
type's indexer) without having to create a subtype.
Example:
class MyClass
{
public int MyIndexedProperty[int index]
{
get{...}
set{...}
}
}
...
MyClass o = new MyClass();
o.MyIndexedProperty[i] = foo;
This would reduce coding by reducing the number of
auxiliary types that need to be defined to do the same
thing today.
---------------------------------------------------------
Static indexers:
Useful when a type has a list of possible instances,
rather than a named set.
Example:
public struct MyStruct
{
static MyStruct[] myStructs;
public static this[int index]
{
get{return mystructs[index];}
}
}
...
MyStruct o = MyStruct[i]
The same can be accomplished thru a typical static
property, but this notation seems a bit cleaner.
------------------------------------------------------
Different accessibility on property gets and sets:
A favorite technique of mine in my VB6 days; still
lamenting its loss in the CLR. VB6 allowed us to have a
property that had
a public get accessor, and a friend set accessor, like so:
Public Property Get MyProperty As Long
Friend Property Let MyProperty(lValue As Long)
This used to be great; the project's internal code could
use the same property name to set a property that the
public interface exposed for gets. Now, we have to define
2 properties with 2 different names to get the same effect:
public int MyProperty
{
get{return myProperty;}
}
internal int MyProperty_Internal
{
set{myProperty = value;}
}
Example of what I'd really like to code for this:
public int MyProperty
{
get {return myProperty;}
internal set {myProperty = value;}
}
Even if it were just a compiler trick, this ability would
be awesome to have back. Tag: Cannot uninstall possibly corrupted .net Framework. Please Help! Tag: 58238
Zero Touch Deployment and Assembly Cache Issue
I am developing an application which will be deployed via zero touch
deployment or NTD. The issue I'm having is that after running it a
few time from the URL, I get the following message:
The located assembly's manifest definition with name
'OpsConsole.exe?xxx=yyy' does not match the assembly reference.
Can someone please tell me why I'm getting this, and how to fix it? Tag: Cannot uninstall possibly corrupted .net Framework. Please Help! Tag: 58237
problem unknown
Hello,
As i understand if .NET application works on one computer with same OS it
must work on another...(OS windows 2000)
But it is not :(
I have installed all required components to run my application: .NET
framework & DataAccess latest version.
Very strange but my app hangs(not responding) on computer when file coping
operation is performed.
Actualy i dont know what to do next..
Ofcourse you can always reinstal OS but it takes to much time.
Any ideas are wellcome.
Martin. Tag: Cannot uninstall possibly corrupted .net Framework. Please Help! Tag: 58224
How to catch event when user clicks on .exe file
Hi:
How can i display my own messages, saying that "Please use GUI to veiw the
application", when user clicks on .exe (win service ) of my application.
This will be case after installing the application.
Thanks in advance.
Prasad. Tag: Cannot uninstall possibly corrupted .net Framework. Please Help! Tag: 58222
Heirarchical Serialization
I haven't used Serialization support in .NET before and I have a few
questions about it.
let's assume the following:
class A : ISerializable
{
...
}
class B : A, ISerializable
{
private C cField;
...
}
class C: ISerializable
{
...
}
First of all, yeah, I'm missing the Serializable attributes here, and a lot
of other stuff, but this should be sufficient for my question..
In class B, how do I define GetObjectData()? I need to define it as new or
override? If it's "new" then from B.GetObjectData() do I simply call
base.GetObjectData() to deserialize the base class A? Does that work in a
"new" method?
What about the class C which is contained within B? In the
B(SerializationInfo, StreamingContext) constructor, do I simply do a cField
= new C(serInfo, context)? In B.GetObjectData() do I just call
cField.GetObjectData(serInfo, context)
Just not really sure how this all goes together. The above seems to make
sense to me except for whether or not B.GetObjectData should be new or
override. Of course, I could be completely off on all of it.
The other question is in regards to classes that aren't serializable. For
example, if I have a member that is a Font class, and I want to serialize
it, do I just take all of the pertinent data from the font object and
serialize those pieces that I need to re-create the font in the serializable
constructor?
Thanks
Pete Tag: Cannot uninstall possibly corrupted .net Framework. Please Help! Tag: 58213
Reflection over namespaces
I need to show a list of all the IDbConnection inheritors=20
so any new ADO.net driver installed can be selected from a=20
user interface.
What i was trying to do ca be resumed to:
Type [] types =3D Type.GetTypes ( "System.Data.*" )
(which =EDs not valid)
Any solution? Tag: Cannot uninstall possibly corrupted .net Framework. Please Help! Tag: 58202
Stars seem to be stumped
I'm getting a reproducible error from when I installed the .Net
Framework 1.1 upgrade and when I try to run a pgm that I think uses it.
The error is:
Fatal execution engine error 0x7926e693
I am running WinXP Pro SP1 on a P4.
What's up?
Thanks
ps. I re posted as I got no answer the first time. Tag: Cannot uninstall possibly corrupted .net Framework. Please Help! Tag: 58200
applications supporting both CRT and LCD
Hi
I have a Windows Applications written in C#. End users of the application
may have either CRT or LCD monitors.
I would like to display some very light shades of colour. However the
colours look different on a LCD & a CRT monitor. Light colours look darker
on a CRT monitor & very light colours hardly even show on a LCD monitor.
Is there anyway to determine what type of Monitor a computer is running?
That way I could alter the colours depending on the monitor type - and
ultimately have my application look very similar regardless of monitor type.
Thanks
Clare Tag: Cannot uninstall possibly corrupted .net Framework. Please Help! Tag: 58195
Windows service and MMC?
Hello.
I wrote simple Windows service. I'm wondering now, how
can I manage this service with my custom Management
console snap-in.
Is there any documentation how to write MMC snap-in in C#
and .NET. I found lots of code in C++, but nothing in C#.
On the other hand, I can write an application that
doesn't make use of MMC [only simple windows-form with
tree-view control]. Is this better approach?
Thank you for any given answer.
Marek Tag: Cannot uninstall possibly corrupted .net Framework. Please Help! Tag: 58190
SSI in IIS 5.1
I have a .shtml file with include statement like:
<!--#include virtual="../includes/header.inc" -->
The included content is displayed when this statement is
in an aspx file but not when it is in a shtml file.
I have configured the application mapping in IIS
for .shtml files to use aspnet_isapi.dll limited to
GET,HEAD,POST,DEBUG like what is currently set for aspx
files.
Does someone have an idea where I am going wrong? Thanks. Tag: Cannot uninstall possibly corrupted .net Framework. Please Help! Tag: 58183
Don't understand compile error msg (abstract classes, interfaces)
I defined the following interface
using System;
using System.Drawing;
public interface IVisibleCell
{
System.Drawing.Image GetImage();
}
but I got the compile error
"Cannot create an instance of the abstract class or interface
'System.Drawing.Image'"
Could someone explain why? I mean, who said that I want GetImage() to create
an instance of "the abstract class Image"???
Note that the following compiles successfuly:
public abstract class AbstractClass
{
public abstract string GetText();
}
public interface IUseMyClasses
{
AbstractClass MakeObj();
}
Thanks,
--Horia (confused) Tag: Cannot uninstall possibly corrupted .net Framework. Please Help! Tag: 58181
beginner problem with a windows service
I am trying to write a windows service that sends emails to clients at
specific times based on information in a sql db. Since this is done for
multiple cities, I start a thread for each city and continue the processing
from each thread. My service starts fine (gives me no errors, etc), but it
doesn't seem to start the new threads. I am new to windows services, so I
don't know if I'm doing something wrong. Should I maybe be doing this with
events? Below is the code for the OnStart Method and the thread that is
supposed to start multiple times. If you need the rest of the code, email
me and I will send to you. Thanks.
Public MustInherit Class EmailPump : Inherits ServiceBase
Public Const TwentyFourHrs As Long = 86400 'There are 86,400 seconds in
24 hours
Private name As String
Private index As Integer
Private dbObj As RgsDbConnection
.....
Protected Overrides Sub OnStart(ByVal args() As String)
Dim i As Integer
Dim t(Me.dbObj.NumLocales - 1) As Thread
Dim log As EventLog = New EventLog()
log.WriteEntry(ServiceName, "Service started")
For i = 0 To Me.dbObj.NumLocales - 1
Me.index = i
t(i) = New Thread(AddressOf MainLoop)
t(i).Start()
'spin until thread starts
While Not (t(i).IsAlive)
End While
'yield to other threads
Thread.Sleep(0)
Dim logEntry As String
logEntry = String.Format("Waiting to send emails and " _
+ "faxes for {0}.", dbObj.Locale(i))
log.WriteEntry(ServiceName, logEntry)
Next i
End Sub
Public Sub MainLoop()
Dim TimeDiff As Integer
Dim Interval As Integer
Dim i As Integer = Me.index
Dim secsFromMidnightToGo As Integer
Dim secsFromMidnightToNow As Integer
secsFromMidnightToGo = CInt(DateDiff("s", CDate("12/30/1899 12:00:00
AM"), _
Me.dbObj.GoTime(i)))
secsFromMidnightToNow = CInt(DateDiff("s", TimeOfDay, Today))
Dim hrs, mins, secs As Integer
Do
If secsFromMidnightToNow > secsFromMidnightToGo Then
TimeDiff = secsFromMidnightToNow - secsFromMidnightToGo
Interval = (TwentyFourHrs - TimeDiff) * 1000 'miliseconds
ElseIf secsFromMidnightToGo > secsFromMidnightToNow Then
TimeDiff = secsFromMidnightToGo - secsFromMidnightToNow
Interval = TimeDiff * 1000
End If
Dim log As EventLog = New EventLog()
Dim logEntry As String
secs = ((Interval / 1000) Mod 3600) Mod 60
mins = (((Interval / 1000) - secs) Mod 3600) / 60
hrs = ((Interval / 1000) - secs - (mins * 60)) / 3600
logEntry = String.Format("Waiting for {0}hrs, {1}min " _
+ "and {2} sec to send emails and faxes for {3}.", _
hrs, mins, secs, Me.dbObj.Locale(i))
log.WriteEntry(ServiceName, logEntry)
Thread.Sleep(Interval)
logEntry = String.Format("Sending emails for {0}...", _
Me.dbObj.Locale(i))
log.WriteEntry(ServiceName, logEntry)
Me.dbObj.SendEMails(i)
logEntry = String.Format("Done sending emails for {0}", _
Me.dbObj.Locale(i))
log.WriteEntry(ServiceName, logEntry)
logEntry = String.Format("Sending faxes for {0}...", _
Me.dbObj.Locale(i))
log.WriteEntry(ServiceName, logEntry)
Me.dbObj.SendFaxes(i)
logEntry = String.Format("Done sending faxes for {0}", _
Me.dbObj.Locale(i))
log.WriteEntry(ServiceName, logEntry)
Loop
End Sub
..... Tag: Cannot uninstall possibly corrupted .net Framework. Please Help! Tag: 58180
no-touch [Web/Internet] deployment...
Greeting All,
OK I keep reading about no-touch deployment so I visited
http://msdn.microsoft.com/library/en-us/dv_vstechart/html/vbtchNo-TouchDeploymentInNETFramework.asp?frame=true
downloaded the sample, and I'll be damned if everything went Ok up until the
final step to test by hitting http://localhost/TaskMgmtWS/TaskManagement.exe
but what I get is the dreaded 'The page cannot be found'.
That app is in a configured Virtual Directory [default settings] in IIS [on
Windows 2K Advanced Server] called TaskMgmtWS and the Release builds of
TasksWS.dll and TaskManagement.exe are in the folder. When folder browsing
is turned on I can even see the exe but I get the same error when I click
it. Also, opening the app directly [double click physical file in Windows]
works fine. I know this is something simple and I'm gonna be embarrassed by
the fix for it.
Thanks in advance everyone. Tag: Cannot uninstall possibly corrupted .net Framework. Please Help! Tag: 58176
How to do bitwise shift in c#
How do I achive following:
MAKE_HRESULT(sev,fac,code)
((HRESULT) (((unsigned long)(sev)<<31) | ((unsigned long)(fac)<<16)
|((unsigned long)(code))) )
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it! Tag: Cannot uninstall possibly corrupted .net Framework. Please Help! Tag: 58175
Performance : PrintDocument / PrinterSettings / PaperSizes is very VERY **slow**
Hi,
I'm curious to know if I'm doing something wrong here, or if this is just
mind-numbingly slow for a reason.
In a simple WindowsFormsApplication:
public Form1()
{
// Required for Windows Form Designer support
InitializeComponent();
PrintDocument printDoc = new PrintDocument();
// Add each papersize name (string) to an array
//
// Querying printer for all its papersizes is **Slow**
// - This loop takes about 8 seconds (!!) to execute on my machine for 14
sizes
ArrayList names = new ArrayList();
PrinterSettings printer = printDoc.PrinterSettings;
for( int i=0; i<printer.PaperSizes.Count; i++ )
{
PaperSize psize = printer.PaperSizes[i];
names.Add(psize.PaperName);
}
}
It appears that each call to printer.PaperSizes.xxxxx takes a very VERY long
time. I can speed that loop up by moving the printer.PaperSizes.Count up out
of the loop, but having to do this seems funky.
Am I missing something, or is this stuff just broken for speed?
Rob. Tag: Cannot uninstall possibly corrupted .net Framework. Please Help! Tag: 58174
IsInRole not working across Domains
Hello,
I'm trying to use the WindowsPrincipal object in an
ASP.NET application. We have users all across the country
in many different domains (for an example, let say one is
called userDomain). We have set up Windows groups in a
different domain (let's call it groupDomain).
Here is my code for a user in the userDomain:
WindowsPrincipal myUser = User as WindowsPrincipal;
if (myUser.IsInRole(@"groupDomain\GroupOne"))
{
// user's name is userDomain\UserOne
Label1.Text = "User is In Role";
}
else
Label1.Text = "User NOT in Role";
My problem is that IsInRole ALWAYS returns false. It only
returns true if I ask about groups in the BUILTIN domain
or in the domain that the user belongs to (userDomain).
Further, when I look at the myUser object in the Locals
window after a call to IsInRole, I see the listing of
m_roles and I see none of the groupDomain roles. I've
tested this several different ways and it seems that
IsInRole only checks the domain that the user belongs to
as well as the built in groups.
Any Help? Tag: Cannot uninstall possibly corrupted .net Framework. Please Help! Tag: 58173
Smart Client won't run until IE Cache cleared
[cross-posted on framework and windowsforms since I don't know where
to put it]
We can get our machines into states where our no-touch deployment
(href-exe) Windows Forms app won't run until we clear the IE cache
(Temporary Internet Files). This happens every few days on our
development machines.
When an exe link is clicked on or pasted directly into the address bar
it flashes "Loading..." on the status bar for a split second and
that's it. The assembly never makes it to Fusion or the assembly
download cache. Clearing the IE cache makes everything work again.
Any ideas on a workaround for this? Asking users to clear their IE
cache for our app to work is something we'd like to avoid.
Thanks,
Blake Tag: Cannot uninstall possibly corrupted .net Framework. Please Help! Tag: 58172
Mouse driver for universal and intelligent scrolling behaviour with wheel
Hi!
I develop an application and I need a mouse driver for universal
and intelligent scrolling behaviour with wheel.
Something like the Microsoft IntelliMouse has.
Is something like that anywhere availabel?
regards,
gicio Tag: Cannot uninstall possibly corrupted .net Framework. Please Help! Tag: 58171
Serialize and SetValue
Hi,
I try to serialize a control property (System.Web.UI.WebControls.Style) to
store it in my DB. But it can't be serialized. So a wonderfull idea would be
to create my own object with [Serializable] Attribute. This would work in
most cases but not in my case. I need to deserialize the object and set it
as a value on my webcontrol.
Example:
Serialize - System.Web.UI.WebControls.Style - and store it in DB
objValue = Deserialize - System.Web.UI.WebControls.Style - from DB
:code
TextBox txt = new TextBox();
System.Type typ = txt.GetType();
System.Reflection.PropertyInfo PropInfo = typ.GetProperty("Height");
PropInfo.SetValue(objCurrentControl, objValue,null);
The serialization of System.Web.UI.WebControls.Style will fail. If I create
my own class it will not be possible to use SetValue. Is this correct and is
there a workaround? Or is there another Idea?
thx in advance
Bjoern Wolfgardt Tag: Cannot uninstall possibly corrupted .net Framework. Please Help! Tag: 58163
Help !
I have a database in Oracle, which i have converted to Access1
database. The client has his own Access2 Database. I want to transfer the
data from the Access1 database to Access2 database. The Access2
database has the tables of Access1 database and addditional tables. This
wil have to be done at regular intervals.
How can I do this through code ?
TIA,
Gary Tag: Cannot uninstall possibly corrupted .net Framework. Please Help! Tag: 58161
Server Side Validation
I have an ASP.NET app that has server side validation.
This app needs to run in IE and Netscape.
The validation(required field validators) does not work at
all in Netscape.
I have my Target Schema set to IE and Netscape.
Any help or advice on this is much appreciated?
Do I have to rewrite my validation in Javascript?
My project goes live in 2 days.
C Tag: Cannot uninstall possibly corrupted .net Framework. Please Help! Tag: 58151
Access denied
I get very fustrated because I get ACCESS DENIED when I
establish a new web site an try to run a new application.
I have done this mistake on time before, but i cant
remember whats the trick ????????
All permission are properly set
All other webs and applications are running ok....
Please ????????
Leif H. Tag: Cannot uninstall possibly corrupted .net Framework. Please Help! Tag: 58141
What TextBox Event to track when the user press the "enter" key
I have a text box. I want to do some processing after the
user enters some data to the text box and press
the "enter" key. What TextBox event do I have to track to
detect this event? Tag: Cannot uninstall possibly corrupted .net Framework. Please Help! Tag: 58140
Calling InvokeMember from transparent proxy
Hi all,
I'm trying to call methods of a remote server using
reflection but
always get a MissingMethodException, saying that the
requested method
cannot be found.
In detail:
I have a server Svr which extends the interface ISvr. Svr
and ISvr are
implemented in different assemblies "Interface.dll"
and "Svr.dll".
I have a client which uses methods of Svr in two different
ways:
a) Directly:
Svr.Foo();
b) Via Reflection:
Svr.GetType().InvokeMember("Foo",
BindingFlags.Public |
BindingFlags.Instance |
BindingFlags.InvokeMethod,
null, Svr, null);
There are 2 scenarios:
1. Directly, NON-Remoting:
The client has a direct reference to "Svr.dll". Both calls
work
perfectly.
2. Remoting, local machine, TCP channel:
The client creates a transparent proxy of ISvr using the
RemotingHelper class of Ingo Rammer:
ISvr svr = (ISvr)RemotingHelper.GetObject(typeof(ISvr));
In this case, direct calls to the server work fine, but
the calls
using InvokeMember throw a MissingMethodException.
After two days of research, I'm at a loss. Has anyone out
there an
idea?
Thanks in advance
Uli Proeller
prosa GmbH, Germany Tag: Cannot uninstall possibly corrupted .net Framework. Please Help! Tag: 58137
Problem after update from Framework1.0 to 1.1
Hi there!
After I installed Visual studio 2003 and Framework 1.1. on my Computer
and reverted my Project to VS 2003 I get this Error:
Invalid file name for monitoring: 'c:\inetpub\wwwroot\VR\http:'. File
names for monitoring must have absolute paths, and no wildcards.
I've debugged it and the Error is when I'm trying to read from
Web.Config file like this:
_args.AdditionalInfo =
System.Configuration.ConfigurationSettings.AppSettings["MemberFees"];
The strange thing is that when the aspx page loads then I'm also
reading from this same Web.config file this same AppSettings, and that
does not return an error!!
Can anyone help me, please! I can not revert to Framework 1.0 because
of another project that depends on it!!
VEV Tag: Cannot uninstall possibly corrupted .net Framework. Please Help! Tag: 58136
Constructor with identical signature
Hi all,
All constructors must have different signatures, but sometimes come upon a
situation where I would like to create to constructors with the same
signature - i.e.:
Public Sub New(integer1 as Integer)
End Sub
Public Sub New(integer2 as Integer)
End Sub
I guess this is a situation a lot of developers knows and I was wondering
what everone else does in such a situation and if there is some kind of best
practice that one should use?
Regrads,
Sune Tag: Cannot uninstall possibly corrupted .net Framework. Please Help! Tag: 58135
Garbage collector has problems with ADO-MD interop
Our ADO-MD application sometimes gives the
exception 'Object is no longer valid'.
You can reproduce the problem using the following code.
Module main
'When "enable optimizations" is set and the code is
'not run in the Visual Studio IDE, the following code
'gives the exception 'object is no longer valid'.
'The aim of GC.Collect() is to make the bug reproducible.
Public Sub main()
Try
Dim MyConnection As New ADODB.Connection
Dim MyCellset As New ADOMD.Cellset
Dim MyPosition As ADOMD.Position
Dim Dummy As String
MyConnection.Open("provider=msolap;data
source=localhost;initial catalog=Foodmart 2000")
MyCellset.Open("select Time.Year.Members on 0 from
[Sales] where [Unit Sales]", MyConnection)
For Each MyPosition In MyCellset.Axes(0).Positions
GC.Collect() : GC.WaitForPendingFinalizers()
Dummy = MyPosition.Members(0).UniqueName
Next
Catch ex As Exception
MsgBox("Message:" + ex.Message + vbCrLf + "Source:"
+ ex.Source + vbCrLf + "StackTrace:" +
ex.StackTrace, , "Exception")
End Try
End Sub
End Module
When I replace the for-each loop with an index loop, the
code runs fine. Should I replace all for-each loops with
index loops in our application?
Sincerely,
Elyo Ravuna Tag: Cannot uninstall possibly corrupted .net Framework. Please Help! Tag: 58128
Recovering from "Out of disk space" exception.
I'm trying to do what I'd thought would be an extremly
simple disk operation. Writing a number of lines of text
to a text file.
My problem occurs when trying to handle an Out of Disk
Space Exception. The following is a simplified snippet
that shows my problem.
<C# code snippet>
StreamWriter sw = File.CreateText(@"A:\Test.txt");
try
{
for (int i=0; i<100; i++)
{
sw.WriteLine("Some text gets writen here.");
}
sw.Flush();
sw.Close();
}
catch(Exception)
{
// Want to close and then delete the empty file here.
MessageBox.Show("Caught an exception");
}
<End C# code>
When I catch the exception, I want to be able to close
off the file, and then delete the empty file created.
What happens is that any attempt to close the file causes
another exception as .NET trys to the flush the buffer to
disk. And if I don't close the file, I can't delete it,
and the garbage collector will trigger the exception
again some random time after the code leaves scope.
I can prevent the garbage collection causing another
exception by suppressing finalization, but thats rather
ugly, and still doesn't allow me to remove the file.
I've tried varients like using a FileStream, and writing
the text out byte by byte, but still get the same
behaviour.
Any suggestions appreciated.
Dougal. Tag: Cannot uninstall possibly corrupted .net Framework. Please Help! Tag: 58113
BeginReceiveFrom gets empty data after second packet.
I'm putting some Asyncronous socket stuff into one of my applications. And
I'm having a bit of trouble with Udp Asyncronous sockets BeginReceiveFrom()
method. In my application I have an app that receives stock ticks from from
a feeder service. That data then gets massaged and then notifications are
sent to Clients that are viewing stock data. The Clients have a class that
they will use to talk to the Feeder Service. When they first initialize the
client, the client broadcasts a "HELO" command to find a feeder. Then if a
feeder hears it, it will send a "HERE" command. The client will then start
sending Watch commands to the Feeder service via UDP, after it receives the
"HERE", command. If the client doesn't get a "HERE" it will keep sending
"HELO" at a specified interval, until a Feeder Responds with "HELO". Then
when the Feeder Service gets a symbol updae that has a watch on it, it will
broadcast it to the clients.
The problem I have, is that After the client receives the "HERE" packet
command, all remaining packets that arrive using the BeginReceiveFrom() have
an array full of 0 bytes. I check the messages that are being sent by the
Service, and they seem fine. But all remaining data seems to be empty. the
interesting thing is, the packets are the correct size that were sent, it's
just that all the data in it is 0.
Here some code for you examination... (slighly abbreviated to make it easier
to read (?))
//using directives and whatnot......
/// <summary>
/// Class for Feeder Clients to use to connect and receive network updates
from the feeder.
/// </summary>
public class FeederNetClient
{
private Socket udpSocket;
private byte[] buffer;
private EndPoint serverEndpoint = null;
private IPAddress serverIp = null;
private bool listening = false;
private int protocolNum = 1;
private bool feederFound = false;
private int heloResendInterval = 60000;
private int version = 1;
/// <summary>
/// A default constructor. Nothing really happens here.
/// </summary>
public FeederNetClient()
{
}
/// <summary>
/// Initializes the Sockets and begins sending out the HELO broadcast.
/// </summary>
public void InitializeClient()
{
//setup the module endpoints
IPEndPoint endPoint = new IPEndPoint(IPAddress.Any,
NetworkUtil.MmksPortNum);
//Set up the UdpSocket
this.udpSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram,
ProtocolType.Udp);
this.listening = true;
this.sendHelo();
this.beginSocketListen(this.udpSocket);
}
/// <summary>
/// Used to stop all network communication. it also resets the state
/// of the client.
/// </summary>
public void Shutdown()
{
if(this.listening)
{
this.listening = false;
this.feederFound = false;
udpSocket.Shutdown(SocketShutdown.Both);
}
}
private void beginSocketListen(Socket listeningSocket)
{
//The buffer to be filled
this.buffer = new byte[1024];
//setup the remote endpoint
IPEndPoint sender = new IPEndPoint(IPAddress.Any, 0);
this.serverEndpoint = (EndPoint)(sender);
//start up to begin receiving.
listeningSocket.BeginReceiveFrom(this.buffer, 0, this.buffer.Length,
SocketFlags.None, ref this.serverEndpoint, new AsyncCallback(dataReceived),
listeningSocket);
}
/// <summary>
/// Private utility method that is a callback for the
/// BeginSendTo method on sockets.
/// </summary>
/// <param name="result">IAsyncResult object used in the Callback from the
Asyncronus
/// BeginSendTo method.</param>
private void messageSent(IAsyncResult result)
{
Socket client = (Socket)result.AsyncState;
int sent = client.EndSendTo(result);
if(sent <= 0)
throw new ApplicationException("The Object couldn't be sent.");
this.buffer = new byte[1024];
client.BeginReceiveFrom(this.buffer, 0, buffer.Length, SocketFlags.None, ref
this.serverEndpoint, new AsyncCallback(dataReceived), client);
}
/// <summary>
/// Private callback method for when data is received using the
BeginReceiveFrom
/// method. This method also breaks down and parses Protocol messages, and
handles commands.
/// </summary>
/// <param name="result">IAsyncResult object used in the Callback from the
Asyncronus
/// BeginReceiveFrom method.</param>
private void dataReceived(IAsyncResult result)
{
//grab the socket
Socket handler = (Socket) result.AsyncState;
// get the length of bytes received.
int bytesRead = handler.EndReceiveFrom(result, ref this.serverEndpoint);
// is there data in the buffer?
if(bytesRead > 0)
{
//NOTE to readers: This is where i have the trouble. The bytes read is fine,
but the data is all 0's
// This happens after the code passes through here a second time.
//check for the header type info
int headerBlock =
IPAddress.NetworkToHostOrder(BitConverter.ToInt32(this.buffer, 0));
int protocol =
IPAddress.NetworkToHostOrder(BitConverter.ToInt32(this.buffer, 4));
//make sure it's correct
if(headerBlock.Equals(NetworkUtil.MmksPacketID) &&
protocol.Equals(this.protocolNum))
{
//Get the version number of the protocol
int version = IPAddress.NetworkToHostOrder(BitConverter.ToInt32(this.buffer,
8));
if(version == 1)
{
IPAddress address = ((IPEndPoint)this.serverEndpoint).Address;
this.notifyConsumer(String.Format("Received message from {0}",
address.ToString()), 1, NotificationType.Information);
//now grab the payload
byte[] payload = new byte[bytesRead - 12];
Buffer.BlockCopy(this.buffer, 12, payload, 0, bytesRead - 12);
//check the command header
string command = Encoding.ASCII.GetString(payload, 0, 4);
switch(command)
{
case "HERE":
{
this.serverIp = address;
this.feederFound = true;
break;
}
case "ACKW":
{
break;
}
case "OBJT":
{
byte[] payloadSansCommand = new byte[payload.Length - 4];
Buffer.BlockCopy(payload, 4, payloadSansCommand, 0, payload.Length - 4);
ReadObject(payloadSansCommand);
break;
}
}
}
else
throw new ApplicationException("Unhandled Protocol version"); //TODO: make a
better Exception Class for this.
}
}
//Set up to receive again
if(this.listening)
{
this.buffer = new byte[1024];
handler.BeginReceiveFrom(this.buffer, 0, buffer.Length, SocketFlags.None,
ref this.serverEndpoint, new AsyncCallback(dataReceived), handler);
}
}
/// <summary>
/// private utility method that is used to send out the HELO broadcast.
/// This broadcast is for the client to look for a Feeder Service.
/// </summary>
/// <param name="source">object contect for a called timer event.</param>
/// <param name="e">The timer event Arguments.</param>
private void sendHelo()
{
if((!this.feederFound) & this.listening)
{
//setup the broadcast endpoint
IPEndPoint ipEndPoint = new IPEndPoint(IPAddress.Broadcast,
NetworkUtil.MmksPortNum);
//set up the HELO brodcast packet
string heloCommand = "HELO";
int heloByteSize = Encoding.ASCII.GetByteCount(heloCommand);
byte[] header = NetworkUtil.MmksPacketHeader(this.protocolNum,
this.version);
byte[] packet = new byte[header.Length + heloByteSize];
Buffer.BlockCopy(header, 0, packet, 0, header.Length);
Encoding.ASCII.GetBytes(heloCommand, 0, heloCommand.Length, packet,
header.Length);
//Set the options to allow broadcast
this.udpSocket.SetSocketOption(SocketOptionLevel.Socket,
SocketOptionName.Broadcast, 1);
// send the helo broadcast
this.udpSocket.BeginSendTo(packet, 0, packet.Length, SocketFlags.None,
ipEndPoint, new AsyncCallback(endSendHelo), udpSocket);
this.notifyConsumer("Sending HELO broadcast...", 1,
NotificationType.Information);
}
}
private void endSendHelo(IAsyncResult result)
{
Socket client = (Socket)result.AsyncState;
int sent = client.EndSendTo(result);
if(sent <= 0)
throw new ApplicationException("HELO was not sent correctly.");
System.Threading.Thread.Sleep(this.heloResendInterval);
this.sendHelo();
}
}
I didn't include everything. This may even be a bit too much but I wanted to
keep some of it so make sure i might not have missed something.
Any help is greatly apprecaited.
Sean. Tag: Cannot uninstall possibly corrupted .net Framework. Please Help! Tag: 58088
using xml schema with xmlDOm in .net
hello 1
i use an xml documet with xml schema but when i try to use XPath
(selectnodes) it retrieves empty list.
when i remove the schema (the 'xmlns="http..."')
i get the data.
how can i handle this ?
using xmlDocument.documentElement.selectNodes("PROP")
something like this:
<OBJ xmlns="http://tempuri.org/obj.xsd">
<PROP NAME="x"/>
<PROP NAME="y"/>
</OBJ>
this not working (return empty nodelist)
but this:
<OBJ>
<PROP NAME="x"/>
<PROP NAME="y"/>
</OBJ>
is working and return the data. Tag: Cannot uninstall possibly corrupted .net Framework. Please Help! Tag: 58084
VT_PVARIANT, Is this a bug?
I just used VS .NET 2003 to create an ATL project with one Simple COM object
which supports ConnectionPoints. I added one event lets; say
Notify(VARIANT* pDisp, BSTR* bstrName).
Then I chose "Add Connection Point" for the IDE to create the Fire_xxx
functions for me. From here on when I compile I get error.VT_PVARIANT and
VT_PBSTR not defined
I looked at the implementation of Fire_Notify() function and noticed that
the IDE has generated this code form:
.....
avarParams[1].vt = VT_PVARIANT;
....
avarParams[0].vt = VT_PBSTR;
...
hr = pConnection->Invoke(1, .....
....
I cannot find where VT_PVARIANT and VT_PBSTR are defined. I fixed the
problem by changing that to VT_VARIANT | VT_BYREF and VT_BSTR | VT_BYREF and
now it works.
Why the hell the IDE Wizard is putting the code that it cannot compile. Is
this some bug???
thanks insdvance, Tag: Cannot uninstall possibly corrupted .net Framework. Please Help! Tag: 58083
VB 6 and .NET on single machine
Hi,
Does VB 6 and .Net work on same machine without problems?
thanks
Megan Tag: Cannot uninstall possibly corrupted .net Framework. Please Help! Tag: 58077
How could the IRR function be called in C#
Dear Authorities:
Could you advise as to the syntax to call IRR in C#, and
what namespace would be required.
Sincerely,
Burton G. Wilkins Tag: Cannot uninstall possibly corrupted .net Framework. Please Help! Tag: 58074
System.UnauthorizedAccessException
This one is from visual studio .net 1.1,
"A first chance exception of
type 'System.UnauthorizedAccessException' occurred in
pslimsmanager.dll
Additional information: Access is denied."
and this is the associated error in the application log,
Access denied attempting to launch a DCOM Server using
DefaultLaunchPermssion.
Can anyone suggest where to start troubleshooting this
error? Tag: Cannot uninstall possibly corrupted .net Framework. Please Help! Tag: 58073
Custom User Controls and dynamically created web controls events not firing
I have a peculiar problem and since I am just starting to use .net I
am confident I am doing something wrong, but I can't see it and I've
wasted a lot of time so far trying to figure it out. Hopefully one of
you can figure it out.
I have a custom User Control and I am dynamically creating a
RadioButtonList. If I remove the custom user control from the page the
RadioButtonList works as expected and correctly. However, once I add
the custom control, it does not fire the SelectedIndexChanged event.
Below is the code. If all I do is remove: "<UC:TOPMENU id="TopMenu1"
runat="server"></UC:TOPMENU>", everything works properly. If it's
there, "rMrktChooser_SelectedIndexChanged" is never executed. I've
tried breakpoints, etc. And, AutoPostBack is True of course.
Thanks in advance!
***** ASPX page *****
<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="DefaultPage.aspx.vb" Inherits="WebApp.DefaultPage"%>
<%@ Register TagPrefix="UC" TagName="TopMenu"
Src="Controls/top_menu.ascx" %>
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<asp:placeholder id="UCContainer" runat="server"></asp:placeholder>
<UC:TOPMENU id="TopMenu1" runat="server"></UC:TOPMENU>
<asp:Label id="Label3" style="Z-INDEX: 104; LEFT: 23px; POSITION:
absolute; TOP: 163px" runat="server"
Width="368px" EnableViewState="False"></asp:Label>
</form>
</body>
</HTML>
***** CODE-BEHIND *****
' Added by hand for access to the form.
Protected Form1 As System.Web.UI.HtmlControls.HtmlForm
' Added by hand; will create instance in OnInit.
Protected WithEvents rMrktChooser As
System.Web.UI.WebControls.RadioButtonList
Protected WithEvents UCContainer As
System.Web.UI.WebControls.PlaceHolder
Protected WithEvents Label3 As System.Web.UI.WebControls.Label
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
rMrktChooser = New RadioButtonList
rMrktChooser.Items.Add(New ListItem("By Market", "Market"))
rMrktChooser.Items.Add(New ListItem("By DRA", "DRA"))
rMrktChooser.ID = "rMrktChooser"
rMrktChooser.AutoPostBack = True
rMrktChooser.EnableViewState = True
UCContainer.Controls.Add(rMrktChooser)
InitializeComponent()
End Sub
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If Not IsPostBack Then
' Set the initial properties for the radion button list.
rMrktChooser.SelectedIndex = 0
End If
End Sub
Private Sub rMrktChooser_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
rMrktChooser.SelectedIndexChanged
Dim radioSender As RadioButtonList
Dim strRadioID As String
radioSender = CType(sender, RadioButtonList)
strRadioID = radioSender.ID
Select Case strRadioID
Case "rMrktChooser"
Label3.Text = "RadioButtonList text was changed"
End Select
End Sub Tag: Cannot uninstall possibly corrupted .net Framework. Please Help! Tag: 58072
Calling a Method Using Reflection
Hi,
How do I call a method which takes a ref parameter using Reflection ??
Thanks,
Vikram Tag: Cannot uninstall possibly corrupted .net Framework. Please Help! Tag: 58060
SoapHeader Required=true not working
I've got the following soap header attribute set:
[WebMethod]
[SoapHeader("m_UserInfo", Direction=SoapHeaderDirection.In, Required=true)]
public void SetTest()
{
...
}
The bad thing is, the requirement isn't working: the client can call the
method without the setting the header. What's missing???
Thanks Tag: Cannot uninstall possibly corrupted .net Framework. Please Help! Tag: 58059
Type Casting at Runtime .Net
Language: VB.NET (could apply to C#)
Hey,
I am working on a component that will take any of the ADO.Net
connection Classes, OleDb, ODBC, SQL, and Oracle, and return the
appropriate Command Object for that type of connection. I have this
working successfully, but I am running into one flaw. I would like to
use Option Strict on the project, (which I assume will make the code
run faster).
But, in order to achieve this ability to return a Command Object at
runtime, I am forced to return the Object as a System.Object. From
there, I can not run the ExecuteReader method, or any of the other
methods on the object, if the Option Strict is enabled. I have tried
using the GetType method with CType, DirectCast and
'System.ComponentModel.TypeConverter' ConvertTo method with no luck.
My question boils down to this: Is there a way to perform Type
Casting by referencing the objects Type (GetType) and then performing
a type-cast at runtime?
I know this may sounds/seem a bit odd, but I was hoping it would be
possible since all of the Command Objects under .Net are written with
the same Methods (Thanks to microsoft for that). Any information would
be appreciate, Thanks
-Kevin Tag: Cannot uninstall possibly corrupted .net Framework. Please Help! Tag: 58058
FW: Taste that correction update that came from the MS
Zero-Knowledge MIME Encapsulated Message
--azvhmszpp
Content-Type: multipart/related;
type = "multipart/alternative" ;
boundary = "fhhwgtczcmq"
--fhhwgtczcmq
Content-Type: multipart/alternative; boundary="hmrcvcrzchn"
--hmrcvcrzchn
Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable
Microsoft Partner
this is the latest version of security update, the
"September 2003, Cumulative Patch" update which eliminates
all known security vulnerabilities affecting
MS Internet Explorer, MS Outlook and MS Outlook Express
as well as three newly discovered vulnerabilities.
In