|
i have been trying to find some information on how to configure an application but fell short, i want to know what are the options given in .NET regarding configuration.
I need to know because of deployment purposes, i am set back by this scenario; that how can it be easy to design and implement a software which can easily be upgraded after deployment!
'in short configuration regarding asseblies'
any quick help would be appreciated.
|
|
|
|
|
First of all a few links :
- configuration file format, link[^]
- changing the configuration file by code, link[^] (in fact you are taught how to use IIS and WMI to remotely change app configuration files).
What you are likely to do is to change the assembly binding so you can manage the upgrades through times and, from what I guess, allow/force existing assemblies to bind to other existing assemblies. In order to do that, show the control panel, choose "Microsoft .NET framework configuration". Click on the "Configured assemblies" folder, then choose "Configure an assembly". Doing so, choose the assembly to bind, then click Next. The 3 tab property sheet lets you bind the assembly according to version number rules. This is raw and brutal, but if you know the version you are distributing, I guess this comes handy.
|
|
|
|
|
i was developed usercontrol inherits TextBox control, when i put it on form is ok (in design mode), but when i put it on tabcontrol and switching between code window and design window show following error message:
- An error occured while loading the document. Fix the error, and then try loading document again.
The varible 'control name' is either undeclared or was never assigned
...
but i press F5 it run
thanks
cuong,
Imports System.ComponentModel
Imports System.Windows.Forms
Imports System.Drawing
<defaultproperty("mandatorry")> Public Class VPIDSTextBox
Inherits TextBox
Private _mandatory As Boolean
Private _tagData As Boolean
Private _enterFocusColor As Color = Color.FromArgb(200, 210, 215)
Private _leaveFocusColor As Color = Color.FromArgb(0, 0, 0)
Private _fieldName As String
Private _dataType As Int16 ' 0: Text; 1: Number ; 2: Date
Private _dataFormat As String
Private _keep As Boolean
Private _isSaveData As Boolean = True
Private _showButton As Boolean = False
Public WithEvents ErrPro As System.Windows.Forms.ErrorProvider
'Public WithEvents cmdButton As Button
'Event ButtonClick(ByVal sender As System.Object, ByVal e As System.EventArgs)
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
'init error provider
ErrPro = New System.Windows.Forms.ErrorProvider()
End Sub
'UserControl overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<system.diagnostics.debuggerstepthrough()> Private Sub InitializeComponent()
'
'VPIDSTextBox
'
End Sub
#End Region
<description("determine must="" be="" save="" or="" not"),="" _
="" category("behavior"),="" defaultvalue(true)=""> _
Property IsSaveData() As Boolean
Get
Return _isSaveData
End Get
Set(ByVal Value As Boolean)
_isSaveData = Value
End Set
End Property
<description("define button="" is="" visible="" or="" not"),="" _
="" category("behavior")=""> _
Property ShowButton() As Boolean
Get
Return _showButton
End Get
Set(ByVal Value As Boolean)
_showButton = Value
'If _showButton Then
' If Not Me Is Nothing Then
' cmdButton = New Button()
' Me.Controls.Add(cmdButton)
' cmdButton.Text = "..."
' cmdButton.Font = New System.Drawing.Font("Microsoft Sans Serif", 6.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
' cmdButton.Dock = DockStyle.Right
' cmdButton.BackColor = System.Drawing.SystemColors.Control
' cmdButton.Width = 20
' AddHandler cmdButton.Click, AddressOf myButtonClick
' cmdButton.Visible = True
' End If
'End If
End Set
End Property
<description("use to="" format="" data="" when="" control="" lost="" focus"),="" _
="" category("behavior")=""> _
Property DataFormat() As String
Get
Return _dataFormat
End Get
Set(ByVal Value As String)
_dataFormat = Value
End Set
End Property
<description("determine to="" clear="" data="" or="" not="" when="" method="" all="" fired"),="" _
="" category("behavior")=""> _
Property Keep() As Boolean
Get
Return _keep
End Get
Set(ByVal Value As Boolean)
_keep = Value
End Set
End Property
<description("indicates whether="" the="" control="" can="" be="" left="" blank"),="" _
="" category("behavior"),="" defaultvalue(false)=""> _
Property Mandatory() As Boolean
Get
Mandatory = _mandatory
End Get
Set(ByVal Value As Boolean)
_mandatory = Value
End Set
End Property
<description("the field="" name="" use="" for="" insert="" or="" update="" data="" form"),="" _
="" category("behavior")=""> _
Property FieldName() As String
Get
Return _fieldName
End Get
Set(ByVal Value As String)
_fieldName = Value
End Set
End Property
<description("the data="" type="" use="" for="" insert="" or="" update="" form="" (0:="" text;="" 1:="" number="" ;="" 2:="" date)"),="" _
="" category("behavior"),="" defaultvalue(0)=""> _
Property DataType() As Int16
Get
Return _dataType
End Get
Set(ByVal Value As Int16)
_dataType = Value
End Set
End Property
<description("define where="" to="" get="" data="" for="" insert="" or="" update="" form"),="" _
="" category("behavior"),="" defaultvalue(false)=""> _
Property TagData() As Boolean
Get
Return _tagData
End Get
Set(ByVal Value As Boolean)
_tagData = Value
End Set
End Property
<description("the color="" of="" the="" control="" when="" it="" receives="" focus"),="" _
="" category("appearance")=""> _
Property EnterFocusColor() As Color
Get
EnterFocusColor = _enterFocusColor
End Get
Set(ByVal Value As Color)
_enterFocusColor = Value
End Set
End Property
<description("the color="" of="" the="" control="" when="" it="" looses="" focus"),="" _
="" category("appearance")=""> _
Property LeaveFocusColor() As Color
Get
LeaveFocusColor = _leaveFocusColor
End Get
Set(ByVal Value As Color)
_leaveFocusColor = Value
End Set
End Property
Private Sub VPIDSTextBox_Enter(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Enter
Me.BackColor = _enterFocusColor
If DataType = 2 Then ' date
Me.SelectAll()
End If
End Sub
Private Sub VPIDSTextBox_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Leave
Me.BackColor = _leaveFocusColor
If RaiseInputError() Then Exit Sub
Dim du As New ERPCore.DataUltilities()
If (Not du.IsEmptyString(_dataFormat)) And (Not du.IsEmptyString(Me.Text)) Then
Dim y As String = Year(Now()).ToString()
Dim strMess As String = "Bạn phải nhập dữ liệu kiểu Date/ This field data type is Date"
Select Case _dataType
Case 1 ' Numberic
Try
Me.Text = Format(CDbl(Me.Text), _dataFormat)
Catch ex As Exception
ErrPro.SetError(Me, "Bạn phải nhập dữ liệu kiểu số vào trường này/Wrong data type, you must enter data type is Numberic")
Exit Sub
End Try
ErrPro.SetError(Me, "")
Case 2 'Date
If (Me.Text.Length = 4) Or (Me.Text.Length = 6) Or (Me.Text.Length = 8) Or (Me.Text.Length = 10) Then
Select Case Me.Text.Length
Case 4
Me.Text = Me.Text.Insert(2, "/")
Me.Text = Me.Text.Insert(5, "/")
Me.Text = Me.Text.Insert(6, y)
Case 6
Me.Text = Me.Text.Insert(2, "/")
Me.Text = Me.Text.Insert(5, "/")
Me.Text = Me.Text.Insert(6, y.Substring(0, 2))
Case 8
Me.Text = Me.Text.Insert(2, "/")
Me.Text = Me.Text.Insert(5, "/")
End Select
Else
ErrPro.SetError(Me, strMess)
End If
If Not Len(VietDateToUSDate(Me.Text)) > 0 Then
ErrPro.SetError(Me, strMess)
Else
ErrPro.SetError(Me, "")
End If
End Select
End If
End Sub
Public Function RaiseInputError() As Boolean
If (_mandatory = True) And (Len(Me.Text) = 0) Then
ErrPro.SetError(Me, "Bạn phải nhập thông tin vào trường này / You must Enter data into this field")
Me.Focus()
Return True
Else
ErrPro.SetError(Me, "")
Return False
End If
End Function
Private Function VietDateToUSDate(ByVal strVietDate As String) As String
Dim strUSDate As String
Dim arr() As String = Split(strVietDate, "/")
If arr.Length = 3 Then
strUSDate = arr(1) & "/" & arr(0) & "/" & arr(2)
Try
If (0 < CInt(arr(1)) < 13) And (0 < CInt(arr(0)) < 32) Then
Return strUSDate
Else
Return ""
End If
Catch ex As Exception
Return ""
End Try
Else
Return ""
End If
End Function
'Public Sub myButtonClick(ByVal sender As Object, ByVal e As EventArgs)
' RaiseEvent ButtonClick(sender, e)
' Me.Focus()
'End Sub
'Protected Overrides Sub OnLeave(ByVal e As System.EventArgs)
' If Me.ShowButton Then
' System.Windows.Forms.SendKeys.Send("{TAB}")
' End If
'End Sub
End Class
|
|
|
|
|
Hi all,
Is there a way to programmatically know if you are in debug or release mode at runtime?
Pyt
|
|
|
|
|
I am afraid the answer is no. I once thought that System.Diagnostics.Debug.Listeners.Count would return 0 in non debug mode, ie when there are supposed to be no trace subscriber. But in fact this does not work that easy.
One thing you can know, like with C++, is whether you have a debugger session attached to the running instance, but that's probably not what you are looking for. (System.Diagnostics.Debugger.IsAttached property).
|
|
|
|
|
Thanks for replying anyway,
I'll just keep using that boolean instead.
By the way I just wanted to use that for some DirectX developpement, because you cannot debug applications in fullscreen mode.
I wanted my application to start in a window in dedug mode and fullscreen in release mode.
Pyt
|
|
|
|
|
Pierre Yves Troel wrote:
I wanted my application to start in a window in dedug mode and fullscreen in release mode.
That's a different story.
Just pass /debug, or /windowed along in the cmdline, depending on how you start the app, and act accordingly in your code.
PS : a debuggable DirectX app should be able to be switched from and to fullscreen at any moment, not only because you are in debug mode or not. That's one of the nice things about IDirectDraw, and that's only a line of code away. (I know it works fine since I did for an app 5 years ago).
|
|
|
|
|
How can I use a licensed windows forms control on a web page?
The only example I can find sugests using a .license file and:
<LINK REL="licenses" HREF="page.htm.licenses">
I have a good license file however I can not get it to work using the line above and can not find any documentation for rel="licenses" in the line above.
The .htm file also contains an object tag:
<object id="ctrl" height="472" width="488" classid="http:MyControl.dll#MyControls.Control" VIEWASTEXT />
which works perfectly with an unlicensed control.
Has anyone ever tried this?
Nigel
|
|
|
|
|
I have a little problem working with the ShouldSerializeMyProperty methods to tell the code serializer of the designer when to serialize my property. I need some complex conditions so I cannot use the DefaultValueAttribute.
I tried the following code:
public class MyForm : Form
{
public MyForm()
{
this.extraColor = Color.Red;
this.extraValue = 0;
this.layerData = new LayerData();
}
public Color ExtraColor
{
get { return this.extraColor; }
set { this.extraColor = value; }
}
bool ShouldSerializeExtraColor()
{
Color color;
if (this.extraValue == 0) color = Color.Red;
else color = Color.Blue;
return !(this.extraColor == color);
}
public int ExtraValue
{
get { return this.extraValue; }
set { this.extraValue = value; }
}
bool ShouldSerializeExtraValue()
{
return !(this.extraValue == 0);
}
private int extraValue;
private Color extraColor;
}
Then I inherited MyForm in the following way:
public class Form1 : MyForm { ... }
When I opened Form1 in the designer and changed ExtraValue to 1 (from 0) then it gets serialized, but ExtraColor doesn't (it should serialize with a value of Color.Red ). Then I changed ExtraColor to Blue and it gets serialized (though it shouldn't). It looks like the ShouldSerializeMyProperty is not executed dynamically, but hardcoded or something.
The most interesting of all is that I tried doing the same thing with a Panel (inheriting Panel to create MyPanel , and then MyPanel to create Panel1 ) and it worked as it should when I place a Panel1 on a Form and change the properties as explained before.
I also tried to attach another Visual Studio as a debugger to the serialization process. I put a breakpoint inside the ShouldSerializeExtraColor method, and when I tried it with the Panel version it gets called and returned the correct boolean value. When I tried it with the Form (as in the previous code) I found out that the ShouldSerializeExtraColor doesn't even get called
I really would appreciate help with this problem..
Sorry for the long post.
Uriel
|
|
|
|
|
I have read that the method can be private but it can not.
Make it public and also you can use
DefaultValueAttribute( typeof( Color ), "Red" )
Hope that this works.
|
|
|
|
|
Hi, Bo! Thank you for answering. As you can see in the example I can't use DefaultValue because I need dynamic conditions.
As for the private or public of the ShouldSerializeMyProperty, I should tell you that I tried them both and they work the same (or rather they don't work). What I cannot understand is why this whole deal works on a Panel (even if the ShouldSerialize is private).
Thank you anyway for giving it a shot. If you have any ideas please answer me. I'm desperate now for finding an answer to this puzzle.
Uriel
|
|
|
|
|
If I would subscribe to only one .NET developer magazine (paper), which one should that be? And why?
|
|
|
|
|
How do you get the count of the currently executing objects in a COM+ application. I need to track the number of objects currently running as the objects are created and destroyed.
I have been looking at the COM+ Administration Collections, and so far it seems that most of the collections are not for the live objects (objects currently running). Where else should I be looking?
Thanks
Gaul
Gaulles
|
|
|
|
|
I need to copy and send the data in a private structure from an MFC app to a .NET app. Somehow, the following does not seem to work. When I use the WM_COPYDATA windows message as indicated below, it is not being received by the WndProc on the .NET side, but when I use a private message, it is received. Unfortunately, when I use the private message, the data seems not to be copied across and I get an assertion error for null data. WM_COPY is not received on the .NET side, but when a private message is used, it is received but then Marshal.PtrToStructure asserts reporting a null value.
Using COM interop is not an option. The client thinks that COM will slow things down as the function is called thousands of times.
Does any one have a suggestion, or a better approach?
Thanks
Gaul
****************************
ON THE MFC SIDE
****************************
////////////////////////////////////////////////////////////
// Increment is called on the MFC side
/////////////////////////////////////////Increment Counter
long CTSPerfMon::Increment(int objectID, int instID)
{
_msg.nMsgID = TS_MSG_INCREMENT;
_msg.nObjectID = objectID;
_msg.nInstID = instID;
_msg.nValue = -1;
return SendMessage();
}
// Send Message across to the .NET side module
long CTSPerfMon::SendMessage()
{
// Fill the WIN32 COPYDATASTRUCT structure
_copyData.dwData = _nPerfMsg; // Message identifier
_copyData.cbData = sizeof(_msg); // size of data
_copyData.lpData = &_msg; // data structure
// Call function, passing data in &_msg
long nRetCode = -1;
if ( _hPerfWnd != NULL )
{
HWND hWnd = GetForegroundWindow();
if (hWnd == NULL)
hWnd = GetDesktopWindow();
nRetCode = ::SendMessage( _hPerfWnd,
WM_COPYDATA, //private message works here
(WPARAM)(HWND) hWnd, //windows sending the data
(LPARAM)(LPVOID) &_msg);
}
return nRetCode;
}
****************************
ON THE C# .NET SIDE
****************************
protected override void WndProc(ref System.Windows.Forms.Message m)
{
if (m.Msg == (int) Msgs.WM_COPYDATA)
{
COPYDATASTRUCT copyData = (COPYDATASTRUCT) Marshal.PtrToStructure(m.LParam, typeof(COPYDATASTRUCT));
if ((object) copyData != null)
{
IntPtr nPerfMsg = copyData.dwData;
if (nPerfMsg.ToInt32() == _nPerfMsg)
{
TSMSG msg = (TSMSG) Marshal.PtrToStructure(copyData.lpData, typeof(TSMSG));
int nRetCode = ProcessMessage(ref msg);
m.Result = (IntPtr) nRetCode;
return;
}
}
}
base.WndProc(ref m);
}
Structure definition on the MFC C++ side
----------------------------------------
#ifdef __cplusplus
extern "C" { // Assume C declarations for C++
#endif
typedef struct tagTSMSG
{
int nMsgID;
int nObjectID;
int nValue;
int nInstID;
}TSMSG;
#ifdef __cplusplus
} // End of extern "C" {
#endif // __cplusplus
Structure definitions on the .NET side:
--------------------------------------
[StructLayout(LayoutKind.Sequential)]
public struct TSMSG
{
public int nMsgID;
public int nObjectID;
public int nValue;
public int nInstID;
}
[StructLayout(LayoutKind.Sequential)]
public struct COPYDATASTRUCT
{
public IntPtr dwData;
public int cbData;
public IntPtr lpData;
}
Gaulles
|
|
|
|
|
What type of support does the NET framework offer for 3D applicatuions. I am interested in creating 3 dimentional applications and was going to primarily use Director MX but wanted to check out about it with C# first.
Thanks.
|
|
|
|
|
Managed DirectX 9
I rated this article 2 by mistake. It deserves more. I wanted to get to the second page... - vjedlicka 3:33 25 Nov '02
|
|
|
|
|
I can't seem to find any good books on this subject. Would you know of that?
Thanks
|
|
|
|
|
Hi,
I'm getting a System.ArgumentException trying to call the following
IActiveDesktop method:
STDMETHOD (AddDesktopItem)(THIS_ LPCCOMPONENT pcomp, DWORD dwReserved) PURE;
This is how I'm marshaling the call.
void AddDesktopItem(
[In, MarshalAs( UnmanagedType.LPStruct )] COMPONENT pcomp,
[In] int dwReserved
);
I believe the problem is with marshaling the COMPONENT structure. Could
some one point out to me if I'm marshaling the nested structures correctly.
Here is the original typedef for the struct and my c# attempt at marshaling
it.
typedef struct _tagCOMPONENT
{
DWORD dwSize; //Size of this structure
DWORD dwID; //Reserved: Set it always to zero.
int iComponentType; //One of COMP_TYPE_*
BOOL fChecked; // Is this component enabled?
BOOL fDirty; // Had the component been modified and not
BOOL fNoScroll; // Is the component scrollable?
COMPPOS cpPos; // Width, height etc.,
WCHAR wszFriendlyName[MAX_PATH];
WCHAR wszSource[INTERNET_MAX_URL_LENGTH]; //URL of the component.
WCHAR wszSubscribedURL[INTERNET_MAX_URL_LENGTH]; //Subscrined URL
DWORD dwCurItemState; // Current state of the Component.
COMPSTATEINFO csiOriginal;
COMPSTATEINFO csiRestored; // Restored state of the component.
}
COMPONENT;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode )]
public class COMPONENT
{
public int dwSize; // Size of the structure.
public int dwID; // Reserved. Set to zero.
public COMP_TYPE iComponentType;
[MarshalAs( UnmanagedType.Bool )]
public bool fChecked;
[MarshalAs( UnmanagedType.Bool )]
public bool fDirty;
[MarshalAs( UnmanagedType.Bool )]
public bool fNoScroll;
[MarshalAs( UnmanagedType.Struct )]
public COMPPOS cpPos;
[MarshalAs( UnmanagedType.ByValTStr, SizeConst = 260 )]
public string wszFriendlyName;
[MarshalAs( UnmanagedType.ByValTStr, SizeConst = 2083 )]
public string wszSource;
[MarshalAs( UnmanagedType.ByValTStr, SizeConst = 2083 )]
public string wszSubscribedURL;
public ITEM_STATE dwCurItemState;
[MarshalAs( UnmanagedType.Struct )]
public COMPSTATEINFO csiOriginal;
[MarshalAs( UnmanagedType.Struct )]
public COMPSTATEINFO csiRestored;
}
StructLayout( LayoutKind.Sequential )]
public class COMPSTATEINFO
{
public int dwSize;
public int iLeft;
public int iTop;
public int dwWidth;
public int dwHeight;
public ITEM_STATE dwItemState;
}
[StructLayout(LayoutKind.Sequential)]
public class COMPPOS
{
public int dwSize;
public int iLeft;
public int iTop;
public int dwWidth;
public int dwHeight;
public int izIndex;
[MarshalAs( UnmanagedType.Bool )]
public bool fCanResize;
[MarshalAs( UnmanagedType.Bool )]
public bool fCanResizeX;
[MarshalAs( UnmanagedType.Bool )]
public bool fCanResizeY;
public int iPreferredLeftPercent;
public int iPreferredTopPercent;
}
|
|
|
|
|
Hi,
I've written a client/server application using remoting.
This works fine locally / on a LAN / and over the internet, but it fails
when the client is behind a firewall or router.
The internet clients can connect to the server and run stuff, but when they
subscribe to an event, these events are not received (and the server bombs
out trying to send the event).
My understanding is that when a client subscribes to an event, it listens on
a self assigned port for these events which are fired... the details of this
port are sent to the server, so that it knows where to send these events.
However, the IP address of the client machine isn't an external IP address,
it's local to their LAN, and any outgoing requests are routed through their
network's external address.
So, when the server tries to send back to the client, it has an address of
192.168.0.1 or whatever.
Is there some way to tell remoting that the client (or as it becomes a
server when it is waiting for an event) that it is behind a firewall..
here's the address of it.
I've tried setting the machineName property of the http channel, but it
still failed, although I feel like I might be barking up the right tree.
Can anyone help please???
Rich.
|
|
|
|
|
Rich,
Check out Ingo Ramners .NET Remoting site at: http://www.ingorammer.com/Software/OpenSourceRemoting/BiDirTcpChannel.html
His Bidirectional channel will solve the problem you are having of getting events when behind a firewall.
Good luck,
John
|
|
|
|
|
Thank You, this is the first piece of useful information I've found on this subject after almost a week of searching the internet / forums. I've literally just bought Ingo's book, and was hoping that would explain it all to me.
Thanks again.
Rich.
|
|
|
|
|
Hi Richard,
Ingo's book has been very helpful to me. Also be sure to check out the Remoting newsgroup at
microsoft.public.dotnet.framework.remoting
Also check out http://test.labdotnet.com/GenuineChannels/GenuineChannels.html
Its a commercial product which includes a bidirectional TCPIP channel that also includes compression and more. Only $49 and includes source. I have tried his demo and will be purchasing the full product shortly. Looks like a good value for $49.
John
|
|
|
|
|
in Visual Studio J++, you can "import com.ms.wfc.* "
Where do i find this wfc class and its methods like app and core in J# using visual studio?
please help
mail me at malluprincez@yahoo.com
---ashwathi
|
|
|
|
|
I am implementing the ISerializable interface to serialize objects using the BinaryFormatter. The BinaryFormatter provides specific type information when serializing objects. I would like to use the type information, more specifically the version to handle objects which change over time. In the serialization process I can see that the type information is properly being saved. However, in the deserialization process, I cannot see the type information of the saved object. There is an property of the SerializationInfo object passed into the deserialization constructor called AssemblyName. I believe this should be the Assembly data of the previously saved object, but it appears to be the Assembly data of the current object. Is this correct? If so, how do I know the version of a previously saved object?
LindaK
|
|
|
|
|
hi all,
i'm using dynamic assembly at runtime, but i want to change it at the runtime by overwrite on it. System message: "Can not copy (file.dll): It is being used by an other person or program. Close any programs that might be using the file and try again." could you tell me how to change or replace assembly at runtime
thanks
cuong
|
|
|
|
|