|
I have no idea why it's blowing up. If you can talk to the person who wrote it, perhaps they can help. One possibility is that I think the threading model of ASP.NET is fixed, perhaps the model of the component needs to change. However, I'm taking a stab in the dark. If you have access to the component's author, then definately being able to add some debugging code or otherwise work out where the exception is thrown is a lot more useful than trying to deal with a black box.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I am trying to find out the version numbers of the components that appear in the Add/Remove programs list.
The data I'm after is stored in the registry BUT I don't seem to be able to access it via code but I can view it usingg Regedit.
Below is the code I'm using to try and access the data. As you can see, I've tried setting the access permission but I'm not entirely sure if my implementation is correct.
If I trim the registry path down to "Software\\Microsoft\\Windows" I get a key returned.
Any ideas???
Cheers,
Ben
<code>
/// <summary>
/// Create a registry key object to allow us to retrieve installed components version numbers.
/// </summary>
/// <returns>The registry key to use if no error occured, else null</returns>
private RegistryKey GetRegistryKey()
{
RegistryKey sysSettingsKey = null;
try
{
// Setup permission to ccess the key
RegistryPermission f = new RegistryPermission(PermissionState.Unrestricted);
f.AddPathList(RegistryPermissionAccess.Read,
"HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall");
// Try and open the key to see if it exists
sysSettingsKey = Registry.LocalMachine.OpenSubKey("Software\\Microsoft\\Windows\\Current Version\\Uninstall");
// Was the key found?
if( sysSettingsKey == null )
{
MessageBox.Show("Unable to access the uninstalll information", "Registry Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
}
catch(Exception ex)
{
MessageBox.Show(string.Format("Exception Detected: \n{0}",ex.ToString()),"Registry Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
return sysSettingsKey;
}
</code>
-- modified at 14:43 Thursday 20th October, 2005
|
|
|
|
|
You're gonna kick yourself.
Wild _Wildy wrote: sysSettingsKey = Registry.LocalMachine.OpenSubKey("Software\\Microsoft\\Windows\\Current Version\\Uninstall");
This works
Wild _Wildy wrote: sysSettingsKey = Registry.LocalMachine.OpenSubKey("Software\\Microsoft\\Windows\\Current Version\\Uninstall");
This needs the space between 'Current' and 'Version' removed, so it's the same as the line above, then it works.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Thanks very much.
I didn't quite kick myself (that would just be silly) but I did drink a few beers and have a laugh about the smallest errors being the hardest to find.
I had got the path from Regedit using the "Copy Key Name" menu item so I don't feel like it was my typo.
Thanks again and Cheers.
|
|
|
|
|
We have a web service that is growing large enough that we wish to seperate logic. Ideally, we would have multiple code files on the server, and the service itself would still appear to be the same to consumers of it.
If we were doing it in c++, we would simply split the implementation of our WebService class across several .cpp. Of course, we can't do that in C#.
Any ideas or pointers to docs?
|
|
|
|
|
Well, in VS2005/C#2.0 you have partial classes if thats what you mean (spreading the implimentation across files). But I don't see why you couldn't just have the webservice methods call methods in other classes.
Matt Newman
Even the very best tools in the hands of an idiot will produce something of little or no value. - Chris Meech on Idiots
|
|
|
|
|
Another part of it is wanting to group methods by thier function; e.g. multiple webservices in one. So from the WSDL, you'd have
Service1<br />
{ <br />
func1();<br />
func2();<br />
}<br />
<br />
Service2<br />
{<br />
func1();<br />
func2();<br />
}
Your information about 2005 helps though - that may end up being our solution.
|
|
|
|
|
What do you mean "large enough"? Is it too large to maintain on the server or is it too large for any client to handle? Any good enterprise application has multiple layers of implementation to facilitate stuff like this. The exposed web service is just another layer in the API so nothing says it needs to needs to match any actual implementation details. You may have 100 objects that that are needed to make the web service "http://server/service" function but changing any one of them shouldn't change the service definition itself. You should be able to modify any of the 100 objects and not have to modify the interface for the web service. If this isn't happening now then you should rethink about the design. Although partial may help, your team should really be asking themselves do they really need a gigantic object so large it needs to span multiple files?
|
|
|
|
|
Most of the logic is in other objects. It's just that this particular .asmx is going to end up being huge and it becomes a pain in the rear to deal with - to add a new function or hunt another down.
|
|
|
|
|
Your team should be spliting the web service *anyway* into more managable functional groups. If you are lumping everything into one giant object then it is a poor design that will cause problems down the road because it will grow like a cancer. Changing one large object/web service is trickier than one small one in an API with hundreds of objects. Regression over one large object/web service is more costly than one of many small ones. Resources consumed for one large object/web service is more "brutal" than many small ones. So on and so forth...
Since it seems like a design issue there is no amount of coding or tricks that will help. The fact you are asking how to do break the object into multiple code files seems to indicate you know what is functionally disperate anyway. If you are already considering breaking up a large object into multiple files then why not break the object along those same functional lines?
|
|
|
|
|
I agree. The problem is I have not been expressing myself clearly.
What I want is multiple web services in the same .wsdl. (Like how MapPoints web service does it.) So the end user only has to know http://foobar/service/Product.asmx?wsdl; so they only need to configure one URL in thier application, rather than have 4 or 5 seperate web services, each with URL and proxy settings configured independantly.
And before any tells me it's not possible, LOOK AT THE WSDL SPEC. Look at Mappoint! sheesh. [/end grouchy part]
|
|
|
|
|
I want to make a form, that I can draw a grid on it, any one have any ideas on this?
Thanks
|
|
|
|
|
Can you explian much more ?
"Praying." Is this only what I can do for him ?
|
|
|
|
|
I have a form, i wand to draw a grid system on the form. Something like this just on a form
<pre>
------------------------------------
| | | | | |
| | | | | |
|----------------------------------|
| | | | | |
| | | | | |
|----------------------------------|
| | | | | |
| | | | | |
|----------------------------------|
| | | | | |
| | | | | |
|----------------------------------|
| | | | | |
| | | | | |
------------------------------------
</pre>
sorry my pic is not the best
|
|
|
|
|
In the paint event of your form draw the lines you need using the graphics object in the paint event. I'd suggest using a loop to draw your horizontal and vertical lines.
|
|
|
|
|
I am trying to create a struct that I can dynamically add multiple elements to at runtime, but for some reason I just can’t grasp how to do this. In VB, I would create a User Defined Type as such:
<br />
Private Type Person<br />
fName As String<br />
lName As String<br />
age As Integer<br />
End Type<br />
And use like so:
<br />
Private Sub Command1_Click()<br />
Dim a As Integer<br />
<br />
a = 5<br />
ReDim x(a) As Crap <br />
<br />
<br />
For y = 0 To 4<br />
x(y).fName = "first" & y<br />
x(y).lName = "last" & y<br />
x(y).age = y<br />
Next<br />
But for some reason I just can’t seem to accomplish this in C#. Can someone please explain this process to me?
|
|
|
|
|
You are looking for an array of structs. Something like
struct Person
{
public string fName;
public string lName;
public int age;
}
void Command1_Click()
{
Person []persons = new Person[5];
for (int i = 0; i<5; ++i)
{
persons[i].fName = "first" + i.ToString();
persons[i].lName = "last" + i.ToString();
persons[i].Age = i;
}
}
BTW, it's recommended to use Properties[^] instead of public variables in structs and classes.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Thanks, that is exactly what I was attempting to accomplish. I will also follow the advice on properties as well.
|
|
|
|
|
What if you wanted to pass the struct as a parameter to method in a different object? Would a struct be the best solution, or is there a better way to that?
|
|
|
|
|
Depends on what your struct contains. If you want value semantics, that is, if you want to pass around a copy of your data everywhere, you can use a struct, otherwise, you can use a class. This[^] might help you decide which one to use.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
My project will be accessing production data off of a *nix box via samba. When the data path is pointing to a local test dataset, or a test set on a remote windows machine everything works fine. But when I change the path to point at a folder on a linuxbox made accessable via samba the application doesn't update.
|
|
|
|
|
From Googling around on this subject, it appears that there are major problems with getting this to work. It doesn't look like there is a great amount of support. About the only thing I could suggest is upgrading the Samba server to the latest and see what happens.
http://www.samba.org[^]
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Dave Kreskowiak wrote: From Googling around on this subject, it appears that there are major problems with getting this to work. It doesn't look like there is a great amount of support. About the only thing I could suggest is upgrading the Samba server to the latest and see what happens.
Bleh. Easier said than done on the client end unfortunately.
|
|
|
|
|
Hello everyone,
I'm trying to 'log' Terminal Server activity. From a fileserver I want to access the Security-logs from the Terminal Server. In those logs we can retrieve log-in and log-out date and times including username.
Offcourse, I did some research... but after a couple of hours i gave up... can't find anything usefull.
<br />
<br />
EventLog elog = new EventLog("test","172.16.2.18");<br />
elog.Log = "Security";<br />
<br />
string one = elog.Entries[i].MachineName;<br />
string two = elog.Entries[i].index;<br />
string etc. etc.<br />
<br />
During my search for the truth out there I came across these classes:
System.Security.Permissions.RegistryPermission
..and..
System.Security.Permissions.SecurityPermission
only I don't know how to apply these classes. Can anyone give me a codesnippet/example?
Thnx in advance!
|
|
|
|
|
i write a Numeric column class Set. But whenever i try to enter any value to numeric cell i got error and application restards itself. Exception is "TargetinvocationException ; Exception has been thrown by the target of an invocation."
NOTE : I create a table at run time, then i bind it to DataGridView. Table has one row at first.
CODE: : : : : :
Imports System<br />
Imports System.Windows.Forms<br />
<br />
#Region "NumericColumn Class"<br />
Public Class NumericColumn<br />
Inherits DataGridViewColumn<br />
<br />
Public Sub New()<br />
MyBase.New(New NumericCell())<br />
End Sub 'New<br />
<br />
<br />
Public Overrides Property CellTemplate() As DataGridViewCell<br />
Get<br />
Return MyBase.CellTemplate<br />
End Get<br />
Set(ByVal value As DataGridViewCell)<br />
' Ensure that the cell used for the template is a NumericCell<br />
If Not (value Is Nothing) And Not value.GetType().IsAssignableFrom(GetType(NumericCell)) Then<br />
Throw New InvalidCastException("Must be a NumericCell")<br />
End If<br />
MyBase.CellTemplate = value<br />
End Set<br />
End Property<br />
End Class<br />
#End Region<br />
<br />
#Region "NumericCell Class"<br />
Public Class NumericCell<br />
Inherits DataGridViewTextBoxCell<br />
<br />
<br />
Public Sub New()<br />
<br />
End Sub<br />
<br />
<br />
Public Overrides Sub InitializeEditingControl(ByVal rowIndex As Integer, ByVal initialFormattedValue As Object, ByVal dataGridViewCellStyle As DataGridViewCellStyle)<br />
MyBase.InitializeEditingControl(rowIndex, initialFormattedValue, dataGridViewCellStyle)<br />
Dim ctl As NumericEditingControl = CType(DataGridView.EditingControl, NumericEditingControl)<br />
ctl.Text = Commas.SetComma(Me.Value)<br />
End Sub<br />
<br />
<br />
Public Overrides ReadOnly Property EditType() As Type<br />
Get<br />
' Return the type of the editing contol that NumericCell uses.<br />
Return GetType(NumericEditingControl)<br />
End Get<br />
End Property<br />
<br />
<br />
Public Overrides ReadOnly Property ValueType() As Type<br />
Get<br />
' Return the type of the value that NumericCell contains.<br />
Return GetType(String)<br />
End Get<br />
End Property<br />
<br />
<br />
Public Overrides ReadOnly Property DefaultNewRowValue() As Object<br />
Get<br />
' Use the current date and time as the default value.<br />
Return "0.00"<br />
End Get<br />
End Property<br />
End Class<br />
#End Region<br />
<br />
#Region "NumericEditingControl Class"<br />
Class NumericEditingControl<br />
Inherits System.Windows.Forms.TextBox<br />
Implements IDataGridViewEditingControl<br />
<br />
Private dataGridViewControl As DataGridView<br />
Private TextIsChanged As Boolean = False<br />
Private rowIndexNum As Integer<br />
<br />
<br />
Public Sub New()<br />
Me.Text = "0.00"<br />
End Sub 'New<br />
<br />
' Implements the IDataGridViewEditingControl.EditingControlFormattedValue property.<br />
Public Property EditingControlFormattedValue() As Object Implements IDataGridViewEditingControl.EditingControlFormattedValue<br />
Get<br />
Return Me.Text<br />
End Get<br />
Set(ByVal value As Object)<br />
'If TypeOf value Is [String] Then<br />
Me.Text = Commas.SetComma(value) 'DateTime.Parse(CStr(value))<br />
'End If<br />
End Set<br />
End Property<br />
<br />
<br />
' Implements the IDataGridViewEditingControl.GetEditingControlFormattedValue method.<br />
Public Function GetEditingControlFormattedValue(ByVal context As DataGridViewDataErrorContexts) As Object Implements IDataGridViewEditingControl.GetEditingControlFormattedValue<br />
Return Me.Text<br />
End Function 'GetFormattedValue<br />
<br />
<br />
' Implements the IDataGridViewEditingControl.ApplyCellStyleToEditingControl method.<br />
Public Sub ApplyCellStyleToEditingControl(ByVal dataGridViewCellStyle As DataGridViewCellStyle) Implements IDataGridViewEditingControl.ApplyCellStyleToEditingControl<br />
Me.Font = dataGridViewCellStyle.Font<br />
'Me.NumericForeColor = dataGridViewCellStyle.ForeColor<br />
'Me.NumericMonthBackground = dataGridViewCellStyle.BackColor<br />
End Sub 'UseCellStyle<br />
<br />
' Implements the IDataGridViewEditingControl.EditingControlRowIndex property.<br />
Public Property EditingControlRowIndex() As Integer Implements IDataGridViewEditingControl.EditingControlRowIndex<br />
Get<br />
Return rowIndexNum<br />
End Get<br />
Set(ByVal value As Integer)<br />
rowIndexNum = value<br />
End Set<br />
End Property<br />
<br />
<br />
' Implements the IDataGridViewEditingControl.EditingControlWantsInputKey method.<br />
Public Function EditingControlWantsInputKey(ByVal key As Keys, ByVal dataGridViewWantsInputKey As Boolean) As Boolean Implements IDataGridViewEditingControl.EditingControlWantsInputKey<br />
<br />
' Let the DateTimePicker handle the keys listed.<br />
Select Case key And Keys.KeyCode<br />
Case Keys.Left, Keys.Up, Keys.Down, Keys.Right, Keys.Home, Keys.End, Keys.PageDown, Keys.PageUp<br />
Return True<br />
Case Else<br />
Return False<br />
End Select<br />
End Function 'IsInputKey<br />
<br />
<br />
' Implements the IDataGridViewEditingControl.PrepareEditingControlForEdit method.<br />
Public Sub PrepareEditingControlForEdit(ByVal selectAll As Boolean) Implements IDataGridViewEditingControl.PrepareEditingControlForEdit<br />
' No preparation needs to be done.<br />
End Sub 'PrepareForEdit<br />
<br />
' Implements the IDataGridViewEditingControl.RepositionEditingControlOnValueChange<br />
' property.<br />
Public ReadOnly Property RepositionEditingControlOnValueChange() As Boolean Implements IDataGridViewEditingControl.RepositionEditingControlOnValueChange<br />
Get<br />
Return False<br />
End Get<br />
End Property<br />
<br />
' Implements the IDataGridViewEditingControl.EditingControlDataGridView property.<br />
Public Property EditingControlDataGridView() As DataGridView Implements IDataGridViewEditingControl.EditingControlDataGridView<br />
Get<br />
Return dataGridViewControl<br />
End Get<br />
Set(ByVal value As DataGridView)<br />
dataGridViewControl = value<br />
End Set<br />
End Property<br />
<br />
' Implements the IDataGridViewEditingControl.EditingControlValueChanged property.<br />
Public Property EditingControlValueChanged() As Boolean Implements IDataGridViewEditingControl.EditingControlValueChanged<br />
Get<br />
Return TextIsChanged<br />
End Get<br />
Set(ByVal value As Boolean)<br />
TextIsChanged = value<br />
End Set<br />
End Property<br />
<br />
' Implements the IDataGridViewEditingControl.EditingPanelCursor method.<br />
Public ReadOnly Property EditingPanelCursor() As Cursor Implements IDataGridViewEditingControl.EditingPanelCursor<br />
Get<br />
Return MyBase.Cursor<br />
End Get<br />
End Property<br />
Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)<br />
MyBase.OnTextChanged(e)<br />
TextIsChanged = True<br />
Me.EditingControlDataGridView.NotifyCurrentCellDirty(True)<br />
End Sub<br />
Protected Overrides Sub OnKeyPress(ByVal e As System.Windows.Forms.KeyPressEventArgs)<br />
Dim asciiInteger As Integer = Asc(e.KeyChar)<br />
Select Case asciiInteger<br />
Case 48 To 57 'Number<br />
e.Handled = False<br />
Case 8 'Backspace<br />
e.Handled = False<br />
Case 46 'Point<br />
If Not Text.Length = 0 Then<br />
If Not Text.Contains(".") Then<br />
e.Handled = False<br />
Else<br />
e.Handled = True<br />
End If<br />
Else<br />
e.Handled = True<br />
End If<br />
Case Else 'Yanlış Giriş<br />
e.Handled = True<br />
End Select<br />
End Sub<br />
<br />
End Class 'NumericEditingControl<br />
#End Region<br />
<br />
<br />
<br />
|
|
|
|