Overriding "OnXXX" versus adding event handler
Okay, this has come up in the past but I haven't seen anything that I
would call a good, solid general rule.
The question applies more generally, but I'm going to ask in the context
of a Control. How does one decide whether to write an "override" method
to an event and when to simply add an event handler for that event?
For example, you can either write a new OnPaint override, or you can
register a delegate that the Control's base OnPaint method will execute.
My current thought is that when you are not inheriting from the base
class, you register a delegate (duh, since you obviously have no way to
override the method in that case), and when you are inheriting from the
base class, you override the method (the main reason here being that if
you're inheriting from the base class, you want your new functionality to
always work, rather than relying on your delegate remaining in the event
handler list).
In other words, override when you can, add an event handler if you can't.
Is it really as simple as that? Or are there other factors I should be
considering?
Many thanks in advance for the wisdom of those who have gone down this
road before me. :)
Pete Tag: How can I get volume ID Tag: 129495
convert an object to string and back (in a culture independent fashion)
to store user preference in our application we have an 'hand written' XML
file. (as opposed to XmlSerializer written one, which crash sometimes, on
some user's computer, for some unknown reason.. but I'm digressing)
In this XML file I store object value, which I convert to string (when
writting) and from string (when reading) with a couple of simple function
which (should) do a reversible conversion (using TypeConverter) (functions
below).
Unfortunately, for some Enum, (namely System.Windows.Forms.Keys) I got a
culture dependent string, even though I specify CultureInfo.InvariantCulture
as an argument in my ConvertXXX method with the TypeConverter. Even using
'new CultureInfo("en")' do not fix this behavior.
Any tip on how to fix these function (below) so they provide a truly culture
independent reversible object=>string=>object mechanism?
===================================================
public static bool TryGetStringValue<T>(object val, out string ret)
{
if (val is string)
{
ret = (string)val;
return true;
}
TypeConverter tc = TypeDescriptor.GetConverter(typeof(T));
if (tc == null)
{
ret = val.ToString();
return false;
}
try
{
ret = tc.ConvertToString(null, CultureInfo.InvariantCulture, val);
return true;
}
catch (ArgumentException) { }
catch (NotSupportedException) { }
ret = val.ToString();
return false;
}
public static bool TryGetTValue<T>(object val, out T tval)
{
if (val is T)
{
tval = (T)val;
return true;
}
TypeConverter tc = TypeDescriptor.GetConverter(typeof(T));
if (tc == null)
{
tval = default(T);
return false;
}
if (!tc.IsValid(val))
{
tval = default(T);
return false;
}
try
{
tval = (T)tc.ConvertFrom(null, CultureInfo.InvariantCulture, val);
return true;
}
catch (ArgumentException) { }
catch (NotSupportedException) { }
tval = default(T);
return false;
}
=================================================== Tag: How can I get volume ID Tag: 129493
Windows Workflow - What basic tutorials? What's going on here?
I thought I was an experienced programmer but I'm looking at the beginning
WWF tutorial (Simple Expense Report) and I'm baffled. I feel like I don't
know how to even begin reading this. I thought this was supposed to be
interactive coding. Since when do we cut and paste into a project file? Is
this just a temporary Beta thing? Why this constant use of command prompts?
Also I have downloaded other samples onto my machine and none of them seem
to work correctly. In the OrderingStateMachine demo, I get the error
message: "The project file <C:\data\Visual Studio
2005\OrderingStateMachine\VB\OrderWorkFlows\OrderWorkFlows.vbproj cannot be
opened. The project type is not supported by this installation." ??????
Could someone direct me to a more user-friendly, comprehensible tutorial? Tag: How can I get volume ID Tag: 129485
Truly cross platform?
The thread bellow titled 'Determining if two paths are the same' brings to
mind some of the first 'things' I had heard way back when DotNet started. It
was going to be the panacea of cross platform development.
I am asking the question here of the group to find out if everyone (anyone)
thinks this has come (or is coming) to fruition.
I think that perhaps it has gone a long way towards making it simpler to
communicate between platforms but I am not sure if the framework itself has
actually made it to the cross platform development hall of fame just yet.
What do you folks think is the possibility of truly doing that? Looking at
the mono project and actually trying to use it in some productive manner has
showed me that this is far off. Just trying to get it working along with GDK
and Mono-develop on a fedora Core 6 system was an exercise in futility.
While I can understand what drives the open source community I honestly can't
understand what keeps it going when stuff is that hard. I can install VS.NET
2005 and be developing in an hour. Hello world in Mono-develop never came to
life. But, I digress and that is another rant for another message area.
So, what are your thoughts and ideas? Tag: How can I get volume ID Tag: 129483
Locking Desktop and Threading Issue
Hi, I have an application that displays forms on the users desktop,
what I am doing with it is having a SystemEvents
SessionSwitchEventHandler to capture the lock of the desktop, I would
like to kill the forms when this event is captured, that piece is
fine, but I would like to sleep the app until the
SessionSwitchReason.SessionUnlock happens then I can wake it again and
go the correct part of the code? Can I wake a sleeping thread, or
should I not sleep the thread at all, is there another way to get the
thread to sleep or hibernate and then wake up?
Thanks
Eamonn Tag: How can I get volume ID Tag: 129478
.Net Windows Service ...data access problem
Hi,
I am writing a .NET windows Service that will access the database every 10
minutes. When the service calls the function in the business services layer
which in turn calls the correponding function in data access layer, this DAL
function fails. The reason 'apparently' being that the it can not read the
connection string information and hence can not create the database
connection.
Please note that that I am using enterprise library. All the projects
representing business service layer, DAL, Model, Web UI and also the the
windows service project are all in the same solution.
Can anyone tell me what should I do to get around this problem.
Thanks
-Sam Tag: How can I get volume ID Tag: 129470
Installation problem - MSDN Libs for VS2005
I'm trying to jury-rig an installation of MSDN for VS2005 from ISO disks.
The company I'm working for has an 'install drive' so I'm not sure of the
pedigree of these directories. Essentially, since I don't have a CD burner
at my disposal, I'm trying to run the installation directly from the ISO
images using Microsoft's Virtual CD-ROM Control Panel v2.0.1.1.
The problem is as follows: It doesn't matter if I run the setup on the
first MSDN disk or call MSDN installation directly from VS2005's setup
screen. Either way I get an error message saying: "Error 1311. Source file
not found. U:\_17693_RTL_x86_enu_NET_Framework_SDK_HxS.cab. Verify that the
file exists and that you can access it."
I should note that given the current mounting scheme, the 3 ISO images are
disks T, U, and V and presumably software on the T drive should be running.
So how could it know about the U drive in the first place and why didn't it
issue a standard Insert Disk prompt? (The file definitely exists and I can
even copy it.) Tag: How can I get volume ID Tag: 129468
Questions about clickOnce
hi,
I have couple of questions about clickonce again,
I am publishing a Winform appplication using ClickOnce. In the 'Publishing
Location' text box I input the directory name
(C:\CLICKONCE\Test2\). In the 'Installation URL' what shall i input. Why do
i need to input a URL when it is
simple Winform Application.
Question2:
When I publish a new version, The client should be prompted about the new
version and it should run that instead of old one.
It doesnt do it in my case, even though 'Application Should check for
updates' is ON.
Thanks in Advance
irfan Tag: How can I get volume ID Tag: 129464
search results dialog box
when i open search from the start menu, i get a listing in the task bar, but
the box cannot be seen. when i click on the task bar block it appears to fly
off the screen to the upper right Tag: How can I get volume ID Tag: 129455
The Interlocked on the Edge of Forever
I've got a quick question that's been bugging me for a long, long time:
Let's say I've got a member variable (in a heavily threaded app):
private int _firstTime = 0;
To make changes to this is easy enough:
InterlockedExchange(ref _firstTime, 1);
... or I can use the InterlockedCompareExchange:
int oldValue = InterlockedCompareExchange(ref _firstTime, 1, 0);
No problems here.
... but, if I just want to read the value, I CANNOT do:
int myValue = _firstTime;
or
if (_fistTime==0)
Doing these requires a memory barrier of some type (volatile variable,
monitor, etc) to have any degree of reliability.
Now, reading the value out using InterlockedCompareExchange always seemed a
bit silly to me. I don't want to always write:
int myValue = InterlockedCompareExchange(ref _firstTime, Int32.MinValue,
Int32.MinValue);
I've never found (although not for lack of looking):
int myValue = InterlockedRead(ref _firstTime);
Of the code that I write, reading the value, and branching based on it's
value, is much more common than writing to the value.
I have, in the past, used volitile variables for this - but I've stopped due
to the various issues regarding volatiles (non atomic reads & writes).
Is there a concensus on the best way to do this? It seems like all the
solutions are.... incomplete.
Essentially I'm looking for a volitile varaiable that is atomically read and
written. Unfortuantly, these don't exist in any language I've yet used.
--
Chris Mullins, MCSD.NET, MCPD:Enterprise, Microsoft C# MVP
http://www.coversant.com/blogs/cmullins Tag: How can I get volume ID Tag: 129446
tcpclient connect security exception - unauthorized
Hi all,
I have a tcpclient and server setup client and server both different
machines. The client when run under administrator credentials connects fine,
but when run under normal user, the tcpclient connect is refused with
unauthorised. All of this is on same netword/domain. The client is running
localy not a network share and connects to specific IP Adress on specific
port. The ony difference between connecting and not is the credentials......
Is this .NET Casol as the socket is accessed, if so how do I resolve it, or
are we looking at windows user permissions?
Any help greatly appreciated...
Pete Tag: How can I get volume ID Tag: 129445
How to tell which window becomes the foregroud window right away?
Hello,
I followed the MS instructions to subclass Windows using C#.net
(http://support.microsoft.com/kb/815775) as the follows. I then opened
several Excel files, and selected anyone of them as foreground window. I was
expecting to see windows message, saying WM_ACTIVATE, or something like that,
however, to my surprise, I saw NO windows message when I randomly selected
those Excel windows, (although I could see other window messages, e.g.,
WM_GETTEXT).
It was said that this was because "Subclassing this way only works for
windows in its own process, not in other applications." Then, is there a way
to make it work on other processes? Will automation will make the "other
application" in the same process of our application?
My goad is: Tell which (e.g. Excel) window becomes the active one AS SOON AS
a (e.g. Excel) window becomes active.
Thanks a lot.
--------------------
Add a new Class module that is named SubclassHWND.cs to the Visual C# .NET
or Visual C# 2005 application. To do this, click Add Class on the Project
menu.
2. In the Name text box, type SubclassHWND.cs, and then click Open.
3. Replace the SubclassHWND class code with the following code:public class
SubclassHWND : NativeWindow
{
protected override void WndProc(ref Message m)
{
// Perform whatever custom processing you must have for this message
System.Diagnostics.Debug.WriteLine(m.ToString());
// forward message to base WndProc
base.WndProc(ref m);
}
}
4. To demonstrate its use, add the following code to the Load event of
Form1:SubclassHWND s = new SubclassHWND();
s.AssignHandle(this.Handle);
//Now s should be listening to the messages of the form. Tag: How can I get volume ID Tag: 129443
some config error happens periodically only
Hi
we have a number of web applications
once in a while they produce an error like below
if you restart IIS - they disappear
it happens on two servers
any ideas?
Thamks
GSL
++++++++++++++++++++++++++++++++++++++++++++++++
Configuration Error
Description: An error occurred during the processing of a configuration file
required to service this request. Please review the specific error details
below and modify your configuration file appropriately.
Parser Error Message: Unable to load file 'portallibrary'.
Source Error:
Line 196: <add assembly="System.EnterpriseServices, Version=1.0.5000.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
Line 197: <add assembly="System.Web.Mobile, Version=1.0.5000.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
Line 198: <add assembly="*"/>
Line 199: </assemblies>
Line 200: </compilation>
Source File:
c:\winnt\microsoft.net\framework\v1.1.4322\Config\machine.config Line:
198
Assembly Load Trace: The following information can be helpful to determine
why the assembly 'portallibrary' could not be loaded.
=== Pre-bind state information ===
LOG: DisplayName = portallibrary
(Partial)
LOG: Appbase = file:///D:/inetpub/Informins_Root/csrportal
LOG: Initial PrivatePath = bin
Calling assembly : (Unknown).
===
LOG: Policy not being applied to reference at this time (private, custom,
partial, or location-based assembly bind).
LOG: Post-policy reference: portallibrary
LOG: Attempting download of new URL
file:///C:/WINNT/Microsoft.NET/Framework/v1.1.4322/Temporary ASP.NET
Files/csrportal/4b3f8fd5/6c4a072e/portallibrary.DLL.
LOG: Attempting download of new URL
file:///C:/WINNT/Microsoft.NET/Framework/v1.1.4322/Temporary ASP.NET
Files/csrportal/4b3f8fd5/6c4a072e/portallibrary/portallibrary.DLL.
LOG: Attempting download of new URL
file:///D:/inetpub/Informins_Root/csrportal/bin/portallibrary.DLL.
LOG: Policy not being applied to reference at this time (private, custom,
partial, or location-based assembly bind).
LOG: Post-policy reference: portallibrary, Version=1.0.2158.24839,
Culture=neutral, PublicKeyToken=null
----------------------------------------------------------------------------
----
Version Information: Microsoft .NET Framework Version:1.1.4322.2032; ASP.NET
Version:1.1.4322.2032 Tag: How can I get volume ID Tag: 129442
Determining if two paths are the same
Hi there,
Given two file names in relative or absolute format, I need to determine if
they point to the same file. While I can simply pass each to
"Path.GetFullPath()" and compare the results, what is the rule regarding
case. That is, how do you determine whether the local file system is
case-sensitive or not. I don't want to assume that Windows is the target OS
even though realistically it will be. Thanks. Tag: How can I get volume ID Tag: 129438
Windows Forms Data Binding problem
Hi,
I builded my very first windows forms application and I used VS.NET 05
wizards to manage a simple Access table, but by now I have a problem:
data aren't updated (without errors) I checked several thinkgs, rows
are showed, but if I do some change and then I click on
databindingnavigator save
button, and then I exit and restart program the data are ...
unmodified...
where I'm wrong?
Thanks!
.:M:. Tag: How can I get volume ID Tag: 129436
Directory Sizes and Performance
Hi all,
I need to regularly traverse a large networked file system and return
a list of directories and their respective sizes. The file system is
large enough that performance is a serious concern.
As well as the recursive [File/Directory]Info solution, I've seen
reference to using the FileSystemObject or calls to FindFirstFile/
FindNextFile via COM interop.
Does anybody know the fastest way of doing this in .Net?
-- Bob Tag: How can I get volume ID Tag: 129434
.net 3.5 framework.
I cannot install any of the new Orcas Express CTP (Beta 1) editions because
they all fail and quit when attempting to install the .net 3.5 framework. I
have the .net frameworks 1.1, 1.1 Hotfix (KB886903), 2.0 and 3.0 installed
on my machine and am running XP SP2. Tag: How can I get volume ID Tag: 129431
.net 3.5 framework.
I cannot install any of the new Orcas Express CTP (Beta 1) editions because
they all fail and quit when attempting to install the .net 3.5 framework. I
have the .net frameworks 1.1, 1.1 Hotfix (KB886903), 2.0 and 3.0 installed
on my machine and am running XP SP2. Tag: How can I get volume ID Tag: 129430
.net framwork 3.5
I recently attempted to install VWD and VD editions of Orcas Express CTP.
They both failed during the installation of the .net framework 3.5 with no
other error message other than stating that they had, in fact, failed
because of .net 3.5.
I have installed on my machine .net frameworks, 1.1, 1.1 Hotfix (KB886903),
2.0 and 3.0. If one or more of these needs to be uninstalled, there was no
instructions to such effect on the Orcas Express CTP installation pages. I
am also running XP SP2.
Any insite on this? Tag: How can I get volume ID Tag: 129429
.net 3.5 framework.
I cannot install any of the new Orcas Express CTP (Beta 1) editions because
they all fail and quit when attempting to install the .net 3.5 framework. I
have the .net frameworks 1.1, 1.1 Hotfix (KB886903), 2.0 and 3.0 installed
on my machine and am running XP SP2. Tag: How can I get volume ID Tag: 129428
Interface & Event
I have an interface ITest that includes an event TestStatusChange.
There is also a class Test that implements ITest. In one of the
functions of Test I want to call the event (see code at the end) but
get the following error:
"The event 'eventTest.Test.TestStatusChanged' can only appear on the
left hand side of += or -=.
All samples I saw seem to do the same I am doing. What am I missing?
Thanks
using System;
using System.Collections.Generic;
using System.Text;
namespace eventTest
{
public delegate void TestStatus(String status);
interface ITest
{
event TestStatus TestStatusChanged;
}
class Test : ITest
{
public event TestStatus TestStatusChanged
{
add { TestStatusChanged += value; }
remove { TestStatusChanged -= value; }
}
public void Check()
{
TestStatusChanged("ok"); //!!!!!!!!! COMPILE
ERROR !!!!!!!!!!!!!
}
}
class Program
{
static void Main(string[] args)
{
}
}
} Tag: How can I get volume ID Tag: 129417
System.Speech
How do I add a reference to System.Speech in Visual Studio?
--
Arne Garvander
(I program VB.Net for fun and C# to get paid.) Tag: How can I get volume ID Tag: 129410
Any groups created for WPF / WCF ?
Hello,
is there any specific newsgroups created for WCF or WPF ?
I tried searching but could not find.. it would be a good idea if Microsoft
can create such newsgroups, will help people developing early applications
on these new technologies. Newsgroup on LINQ would also be a good idea.. !
:)
Regards,
Jigar Mehta Tag: How can I get volume ID Tag: 129406
DataSet fields not updating, no errors being generated
I am using a web service to update some database fields. I used the
dataset designer to define my datatable and tableadapter. I had it
automatically create the insert, update, and delete statements.
When I run the update method, all of the fields are updated except for
four datetime fields. Another attribute these fields have in common is
that they allow nulls. When the method runs, the values in the fields
are not overwritten, they are simply not changed.
Here is the code used for the updating:
PurchaseOrderTableAdapter dAdapter = new PurchaseOrderTableAdapter();
PoDataSet.PurchaseOrderDataTable ds =
dAdapter.GetDataByPoID(poID);
foreach (PoDataSet.PurchaseOrderRow dataRow1 in ds)
{
dataRow1["PONumber"] = poNumber;
dataRow1["ConfirmingTo"] = confirmingTo;
dataRow1["poDate"] = poDate;
dataRow1["ReqDate"] = reqDate;
dataRow1["CancelDate"] = cancelDate;
dataRow1["AllowBackOrder"] = allowBackOrder;
dataRow1["ShipTo"] = shipTo;
dataRow1["BillTo"] = billTo;
dataRow1["ShipVia"] = shipVia;
dataRow1["FOBPoint"] = fobPoint;
dataRow1["Terms"] = terms;
dataRow1["IsPlaced"] = isPlaced;
dataRow1["placeDate"] = datePlaced;
}
try
{
dAdapter.Update(ds);
}
catch (Exception e)
{
return 1 + e.Message;
}
return "0";
I am new to C# and .net in general. Any ideas as to why this method is
not updating the "placeDate", "poDate", "ReqDate", and "CancelDate"
fields? The variables used are defined as DateTime types. As I said,
there are no errors flagged during the process.
Your advice is greatly appreciated.
-- Alex Tag: How can I get volume ID Tag: 129403
Service running Infinitely
Hi,
I'm developing a service that should run infinitely and should not be
stoppable. The
user (any user even admin) should not be able to stop/terminate the
service.
Is there any way? or should I go for a normal other than service?
Any recommendations are appreciated.
thanks Tag: How can I get volume ID Tag: 129400
Converting source code to another language?
Is it possible to convert source code from one language into another
using the codedom ICodeParser interface?
Has anyone ever tried it? Tag: How can I get volume ID Tag: 129398
Need help on CAB
I'm a new bie to cab...need some info on displaying a new child window using
CAB...
My requirement is to show a new form if I click on teh File menu option on the
Main Windows form..
So,I've created a shell with File -> New menu option...but and registered
a click event with the New menu button oiption..but the problem is like I'm
unable to dsiplay the new form in child window....currently my new form
appears in the
parent window only....How do I display data in a child window using CAB
framework..
can anyone help me out Tag: How can I get volume ID Tag: 129397
Retrieving data from a Windows Service
Hi,
I have a collection that resides in a windows service and I want to
know is remoting the best way to access this data? The collection
will change on an ongoing basis, but whenever I make a request to the
windows service I want to be able to get back the latest elements in
the collection.
Should I use remoting an expose my object as a Singleton? Is there a
better way to do this?
Thank you.
Greg Tag: How can I get volume ID Tag: 129395
deadlock on a single Select not in a transaction
Hi,
We have a web application developped in asp.net (I think it's not relevant,
but well, it's so you know)... Yesterday, we received the following message
"Transaction (Process ID 69) was deadlocked on lock resources with another
process and has been chosen as the deadlock victim. Rerun the transaction. "
The thing is, the query was a simple select with inner joins between 3
tables (like select fields from table1 inner join table2... inner join
table3....). This command is not in a transaction, so the deadlock seems
impossible. And moreover, the deadlock occurs on the DataReader.Read() not
on the Command.ExecuteReader(...).
Can someone explain why the deadlock can have occured and what could be the
cause and solution to it? Can it be a bug in SQL Server or in the .net
framework (I really doubt about it)?
thanks
ThunderMusic Tag: How can I get volume ID Tag: 129387
EventTraceLogListener and error?
I started with the logging application block in the April 2007 Enterprise
Library. Looking through the source it looks like when it comes to the event
log they just inherit the EventTraceLogListener class. It seems to work. I
look via the EventViewer and can see messages that are place there via my
app. Is there a way to specify that the entry is an error? warning? Something
other than "Information"?
Thank you.
Kevin Tag: How can I get volume ID Tag: 129386
Subclassing question.
Hello,
I followed the MS instructions to subclass Windows using C#.net
(http://support.microsoft.com/kb/815775) as the follows. I then opened
several Excel files, and selected anyone of them as foreground window. I was
expecting to see windows message, saying WM_ACTIVATE, or something like that,
however, to my surprise, I saw NO windows message when I randomly selected
those Excel windows, (although I could see other window messages, e.g.,
WM_GETTEXT).
What was wrong here? I need to be able to tell which Excel window is the
active one programmatically. Was this a right approach for this purpose? Any
papers?
Thanks a lot.
--------------------
Add a new Class module that is named SubclassHWND.cs to the Visual C# .NET
or Visual C# 2005 application. To do this, click Add Class on the Project
menu.
2. In the Name text box, type SubclassHWND.cs, and then click Open.
3. Replace the SubclassHWND class code with the following code:public class
SubclassHWND : NativeWindow
{
protected override void WndProc(ref Message m)
{
// Perform whatever custom processing you must have for this message
System.Diagnostics.Debug.WriteLine(m.ToString());
// forward message to base WndProc
base.WndProc(ref m);
}
}
4. To demonstrate its use, add the following code to the Load event of
Form1:SubclassHWND s = new SubclassHWND();
s.AssignHandle(this.Handle);
//Now s should be listening to the messages of the form. Tag: How can I get volume ID Tag: 129385
On Adobe's Flash & Flex in ASP.NET
I have been asked to create some simple animation using Adobe Flash player
in ASP.NET(C#) web application.
While I am fairly well versed with ASP.NET C#, I absolutely have NO IDEA
about how to say "Hello World" in a Flash enabled web page rendered via
ASP.NET.
Can any one let me get started?
---
By the way, there is a NEWS today about Adobe Flex 2, which I can not
comprehend. There are getting started articles for PHP developers on Adobe's
website but nothing for ASP.NET developers.
http://news.com.com/Adobe+to+open-source+Flash+tool+Flex/2100-7344_3-6179305.html
It will be nice to hear something from experienced people. Microsoft folks
too are urged to speak something. How Microsfott's Silverlight fits into all
this? Can a person who rely solel on VWD/C# Express count on Silverline?
Thanks in advance !
-- a VWD(C#) Express explorer Tag: How can I get volume ID Tag: 129376
additional files in clickonce
hi,
I want to add some CAD files or Excel Templates when i publish using
ClickOnce. Is there any way i can do it.
Thanks
irfan Tag: How can I get volume ID Tag: 129374
clickOnce Update not working
hi,
I created a clickonce application and installed it in the client machine. As
expected a new shortcut is created in the
Start->All Programs.
However, when i publish the application again after making some changes, i
expect that the newer version should run when i click
on the shortcut, which does not happen in my case.
Can some one tell me if i am doing anything wrong.
(On the publish page "Application should Check for updates" is ON).
(The application is a basic Winforms application)
regards,
irfan sheikh Tag: How can I get volume ID Tag: 129373
How to capture Item's event through an object of its collection in a external class?
There are two classes
1) Key - contains some public variables, one method "Reset" and one
event "valuesReset" which is raised by Reset method.
2) Keys - this class is collection of objects of class 'Key' and it is
inherited with ReadOnlyCollection(Of key).
I'm pasting the code here
Class key
Public Event valuesReset()
Public _name As String = ""
Public _title As Integer = 0
Public _strong As Integer = 0
Public _italic As Integer = 0
Public Function reset() As Boolean
_name = ""
_title = 0
_strong = 0
_italic = 0
RaiseEvent valuesReset()
End Function
End Class
'Collection of key
Class keys
Inherits ReadOnlyCollection(Of key)
Friend Sub New()
MyBase.New(New List(Of key))
End Sub
Friend Function add(ByVal tmpKey As key) As Integer
If Items.Contains(tmpKey) Then
Return Items.IndexOf(tmpKey)
End If
Items.Add(tmpKey)
Return Count - 1
End Function
Friend Sub AddAt(ByVal tmpKey As key, ByVal index As
Integer)
If index < 0 OrElse index > Items.Count - 1 Then
Return
End If
If Contains(tmpKey) Then
Return
End If
Items.Insert(index, tmpKey)
End Sub
Friend Sub Dispose()
For i As Integer = Count - 1 To 0 Step -1
Me(i).reset()
Next
End Sub
Friend Sub remove(ByVal tmpKey As key)
Items.Remove(tmpKey)
End Sub
End Class
Class Form1
withevents objKeys as Keys
' I want to capture the "valuesReset" event here with
the index number of the key type
' bject
End Class
Now the problem is how can I capture the event "valuesReset" of an key
object if I use
"withevents objKeys as Keys" in any form/outside class? and if it is
possible how can I know which key object inside the collection has
raised the event? Thanks In advance :-) Tag: How can I get volume ID Tag: 129371
How to capture Item's event through an object of its collection in a external class?
There are two classes
1) Key - contains some public variables, one method "Reset" and one
event "valuesReset" which is raised by Reset method.
2) Keys - this class is collection of objects of class 'Key' and it is
inherited with ReadOnlyCollection(Of key).
I'm pasting the code here
Class key
Public Event valuesReset()
Public _name As String = ""
Public _title As Integer = 0
Public _strong As Integer = 0
Public _italic As Integer = 0
Public Function reset() As Boolean
_name = ""
_title = 0
_strong = 0
_italic = 0
RaiseEvent valuesReset()
End Function
End Class
'Collection of key
Class keys
Inherits ReadOnlyCollection(Of key)
Friend Sub New()
MyBase.New(New List(Of key))
End Sub
Friend Function add(ByVal tmpKey As key) As Integer
If Items.Contains(tmpKey) Then
Return Items.IndexOf(tmpKey)
End If
Items.Add(tmpKey)
Return Count - 1
End Function
Friend Sub AddAt(ByVal tmpKey As key, ByVal index As
Integer)
If index < 0 OrElse index > Items.Count - 1 Then
Return
End If
If Contains(tmpKey) Then
Return
End If
Items.Insert(index, tmpKey)
End Sub
Friend Sub Dispose()
For i As Integer = Count - 1 To 0 Step -1
Me(i).reset()
Next
End Sub
Friend Sub remove(ByVal tmpKey As key)
Items.Remove(tmpKey)
End Sub
End Class
Class Form1
withevents objKeys as Keys
' I want to capture the "valuesReset" event here with
the index number of the key type
' bject
End Class
Now the problem is how can I capture the event "valuesReset" of an key
object if I use
"withevents objKeys as Keys" in any form/outside class? and if it is
possible how can I know which key object inside the collection has
raised the event? Thanks In advance :-) Tag: How can I get volume ID Tag: 129370
Custom control loading order
Hi, I have a custom control which loads data, with some critera from a
property of the hosting UserControl.
I try to get the property value on BindingChanged in my custom control,
but, at that time, host UserControl is not completly loaded, so my
property is NULL.
I can't call a custom control's method from host UserControl. It would
'destroy' the automatic behaviour...
How can I know in my custome control that the host UserControl has
finished to load ?
TIA Tag: How can I get volume ID Tag: 129361
Build "Release" for asp.net website
I build a website solution by using visual studio 2005, how can I build the
"release" version, because I just find the "debug" in the IDE and it seems
it's necessary to append the configuration manually.
--
ISAMUSETU Tag: How can I get volume ID Tag: 129350
why use .net?
Hi there,
We need to retrospectively justify our choice in using .NET framework for
developing our site. Our techie isnt here so we cant run it past him. Can
some kind, helpful person run their eye over it and tell me if I'm tellling
porkies, or if there is anything I should add?
Why should people choose .net (I think ours is 1.1)
Thanks
Gay
******************
We recognised that in order to meet our aims of producing a high quality and
consistent website, we had to ensure that our system was fast, robust and
able to deal with a high number of users.
We chose .NET framework so that we could meet these needs now, but also so
that we could best account for any future developments in a cost effective
manner. This has proved the case, in that with our Stage 2 developments we
will be implementing a forum system. Using .NET has meant that we can
integrate new modules with ease. With .NET's cross-platform
interconnectivity, we feel that we have chosen the best approach for
future-proofing. Tag: How can I get volume ID Tag: 129346
What can we do in C#.net with a given window handle?
Hello, friends,
What can we do in C#.net with a given window handle? For example, can we
activate or close this window? How? Any reference papers?
Thanks a lot. Tag: How can I get volume ID Tag: 129344
Piped input contains Unicode preamble
I'm an old dog and I like old tricks, so I write a lot of utilities that
accept piped input.
e.g.
TYPE mydata.txt | MyApp
or
MyApp < mydata.txt
or
App1 | App2
Then read the input with System.Console.In
What I found though is that if the input file contains a Unicode preamble
(i.e. EF BB BF for UTF-8) the preamble appears in the data, which is
inconvenient.
I'm not real interested in _why_ this is the case, but I wonder what others
do to resolve this.
So far, because I'm only concerned with "ASCII" text, I simply ignore all
characters above 7F, but I'd like a more elegant solution.
One other thing I tried was rather than use
System.Console.In
I tried
new System.IO.StreamReader ( System.Console.OpenStandardInput , true )
which worked some times, but other times was missing the beginning of the
data (which I assume is due to buffering). Tag: How can I get volume ID Tag: 129343
"The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel"
Alright Googler Groupers!
I've searched high and low and tried everything I care to, so I'll see
what the masses can conclude! I'm making both UPS and PayPal calls and
both of them *occaisionally* throw this error. Please help!
The error I receive is :
"The underlying connection was closed: Could not establish trust
relationship for the SSL/TLS secure channel"
The inner exception is:
"The remote certificate is invalid according to the validation
procedure"
My web.config has:
<system.net>
<settings>
<servicePointManager checkCertificateName="false"
checkCertificateRevocationList="false"/>
</settings>
<connectionManagement>
<add address="*" maxconnection="12"/>
</connectionManagement>
</system.net>
My Global.asax has:
ServicePointManager.CertificatePolicy = new CertificatePolicy();
ServicePointManager.ServerCertificateValidationCallback = new
RemoteCertificateValidationCallback(ValidationCallBack);
My CertificationPolicy class looks like:
public bool CheckValidationResult(ServicePoint sp, X509Certificate
cert, WebRequest req, int problem)
{
return true;
}
And finally, my code is:
HttpRequestHandler http = new HttpRequestHandler(connectionURL);
string response = http.POST(stuffToPost); Tag: How can I get volume ID Tag: 129342
Custom app and Korean
I have an application written in .NET, running under Windows XP SP2 and
Windows Server 2003 with SQL Server 2000 as the backend. This app basically
indexes documents to allow keyword searching.
We now need to load and index Korean language documents, but I have
absolutely no idea what would be necessary to accomplish this.
First off, we do use a third party product to perform the indexing, and I
know that it supports Unicode.
Any pointers and assistance would be appreciated.
Michael Tag: How can I get volume ID Tag: 129338
managed API equivilent to WNetAddConnection
Hi,
I'm wondering if there is a managed class/method that is equivilent to the
WNetAddConnection API. I am writing an app that is required to connect to
various network resources without knowing whether those resources are
connected before hand. I also need the functionality of being able to
provide profile/password information when attempting to access the network
resources. So far I haven't found anything that will work, but if anyone
knows a way, I would appreciate hearing about it. Thanks.
Kristofor Tag: How can I get volume ID Tag: 129336
Invert of background color
Hi,
I have color as System.Drawing.Color c1 object as background color. Now I
would like to get another System.Drawing.Color c2 object which is invert of
c1 color to be used as foreground color.
e.g if I have c1 as black and I should get c2 as white.
Thanks,
Mahesh Tag: How can I get volume ID Tag: 129334
Dotnet framework 3.0 questions
Hi check this for your questions on dot net framework 3.0
http://dotnetintervies.blogspot.com
Preeti Tag: How can I get volume ID Tag: 129333
Network communication with Windows Services
Hello,
I am designing an system where Windows services (clients) are
distributed across a company LAN. The clients are written in Win32
since not all network machines may not have .NET Framework
installed. The clients connect to a central SQL database to report
relavent status information from the network machines. There is a
WinForms application that monitors and provides results of the
distributes clients to an operator. The application also allows the
operator to deploy the clients to the remote machines via Windows
Networking APIs, or externally using Active Directory and a supplied
Windows Installer Package that installs the Windows Service client out
to the network.
The target network(s) are Windows based using Active Directory. The
client machines are Windows 98 and above....however, we may limit the
requirements to only support Windows 2000 and above if necessary.
I was hoping some of you can provide your opinions on the following
questions:
1) Given the above design/architecture, do you think there are other
or better methods for implementing the system? ie, any other
technologies that would better suite the situation other than each
client directly connecting to SQL Server...
2) Please comment on the idea of using a web service (installed on the
database server) for clients to connect to provide status information?
3) Are there other or better technologies for distributing the Windows
Service clients outside of the ones mentioned above? Note, this
system will be used on a broad range of networks that may not have
specific technologies in production.
Thanks in advance for your input. Its always good to get other
opinions. Tag: How can I get volume ID Tag: 129332
Doing "using" with CodeDom?
Is there any way to do "using" with the CodeDom?
using(SqlConnection connnection = new SqlConnection("..."))
{
}
Kevin Tag: How can I get volume ID Tag: 129331
XmlNode.InnerXml and Xml Readers / XmlDocument
Hi,
I am currently working on xml files and i am trying to ensure that my code
handles any encoded chars (like > < & ' stored as < > " ' )
I am currently using XmlValidatingReader.ReadInnerXml() but i have noticed
the behavior with XmlDocument too.
assume that i am trying to read a node which looks like this
<exlObjectFields>
<it:DSPLY_NAME><test"invalid"></it:DSPLY_NAME>
<it:OFFCL_CODE>TFMS000000</it:OFFCL_CODE>
<it:BCKGRNDPAG>TFMS000000</it:BCKGRNDPAG>
</exlObjectFields>
The DSPLY_NAME Field code that is read looks like this
<it:DSPLY_NAME><test"invalid"></it:DSPLY_NAME>
As you can see. the < > not decoded but " is being decode back to " char. It
there any ways i could force it to read without automatic decoding certain
chars ? Is it a bug ?
TIA
--
Regards,
Hermit Dave
http://www.invokeit.co.uk Tag: How can I get volume ID Tag: 129326
Hello.
How can I get volume ID on which I have open file?