User controls
Hi
I am writing (practicing) a small game using user controls
and some time my control whould become over another same type
or another type user or windows control
how can I modify the layout , some thing like Z coordinating in my
controls???
Thank you Tag: Free components Tag: 108687
strong-name - framework 1.1 and framework 2.0
Hi guys,
I have an application that is a asp.net and uses some dlls.
This dlls are signed with a strong-name key.
When I sign a dll using framework 1.1 and a file.snk I get a key XXX.
And when I sign dll using framwork 2.0 and the same file.snk I get a key ZZZ.
(command to get a key from dll: sn -T file.dll)
Why does it happen ? Should I not see the same key ?
TIA,
wrampazo. Tag: Free components Tag: 108686
How to find a block in Finalize()?
Hello,
I'm using .NET Framework 1.1, C#. A couple of days before I've found out
that my application leaks memory not releasing objects with destructors. I'm
using some third-party components (Spring.NET and Oracle Data Provider .NET
(ODP.NET is actually a leak in my case)). I know that it's a good habit to
call Dispose() if the object is IDisposable, but in my case I cannot do this,
and need to rely on destructor (performance loss was considered).
Then I've tried to reproduce the problem in a small test project (with only
ODP.NET objects) and failed :(. The leak was away.
Now I suspect that Spring.NET/ODP.NET somehow blocks the finalizer thread,
so that it never clears the garbage left.
Justification:
/// <summary>
/// Create a new session
/// </summary>
/// <returns>The new session that can be used by the client.</returns>
public ISession CreateSession()
{
GC.Collect();
GC.WaitForPendingFinalizers(); //Application hangs here
GC.Collect();
GC.WaitForPendingFinalizers();
new Message(Message.MessageType.CalledCreateSessionOn0,
this.GetType().FullName).LogDebug();
ISession session = (ISession)
Application.CreateSession()[typeof(ISession).FullName+".Remote"];
return session;
}
This method will be called relatively early after the client starts (server
and client interact over normal MarshalByRef objects, there is anyway not
much interaction there...). It is practically the first client call on the
server side. Before the first client starts there will be some Spring.NET
initialization done and an OracleConnection opened and closed (to check that
the database is available).
The problem is that this code hangs on the first call to
GC.WaitForPendingFinalizers(). By "hangs" I mean that nothing else will be
done in application - no log messages, in Visual Studio I can pause/stop
application (shows me a Console.ReadLine(); line - is not relevant). I've
been waiting for 15 minutes - no changes. The memory leak was found out by
ANTS Profiler and is definitely there. :(
I've also installed WinDBG in order to find out where the finalizing thread
is blocked, but had not much advance on that field (starting from that I do
not know which of threads is finalizing thread).
I have source code for Spring.NET, but it is really huge and not quite
understandable. I would be happy if I'll find out that the problem is really
in Spring. Can anyone help me, please? Do I actually force the garbage
collector in a correct manner (Collect/WaitForFinalizers,
Collect/WaitForFinalizers)? How can I find out what the finalizing thread is
actually doing? Does the observed behaviour (hang on
WaitForPendingFinalizers) actually an evidence that there are problems in
finalizer?
Thank you in advance. Tag: Free components Tag: 108685
problem with special characters in password
We have a case where users who are encouraged to have good passwords with
norwegian characters and other special characters cannot login to a ASP.NET
1.0 app.
This problem is discussed in the following article from MSKB:
http://www.kbalertz.com/kb_835388.aspx
Do you know if this problem is fixed in later versions of the framework?
I.e. servicepacks, 1.1 or 2.0.
Thanks.
--
_________________
Rolf @ Questus ans Tag: Free components Tag: 108684
Exception from dialog not catched on Windows x64 box?
Hello.
I've installed VS 2003 on my Windows XP x64 box. And catched the
problem: if exception is thrown from some window ShowDialog it is not
catched by catch followed by ShowDialog.
Somewhere in the VisibleChanged dialog form handler exception is
thrown.
private void Dialog_VisibleChanged(object sender, System.EventArgs e)
{
if (Visible == false)
throw new ApplicationException("test exception from dialog");
}
On Windows XP x32 box it is catched after dialog is displayed.
try
{
using (Dialog d = new Dialog())
{
d.ShowDialog();
}
}
catch(Exception ex)
{
MessageBox.Show(string.Format("exception catched\r\n{0}",
ex.Message));
}
When code is build on Windows XP x64 exception is not catched :( How it
could be possible?
Compleete test could be downloaded from
<http://spot9969.multiply.com/video/item/1> (11KB, VS 2003) Tag: Free components Tag: 108683
Detect the encoding of a stream
Hi,
Is there a way in which I can detect the encoding used while creating a
StreamReader? I have a method which receives a StreamReader as a
parameter. I want to ensure that when I do a
StreamReader.BaseStream.Seek() , I give the appropriate offset so that
encoding information/byte order marks are not read in (In case the file
uses UTF8 or Unicode encoding). Is there a standard way to do that?
Thanks,
Roshan Tag: Free components Tag: 108678
Free tool to compress and pack .NET assemblies (embed DLLs is single EXE )
.NETZ is a free open source tool to compress .NET EXE and DLL files,
writen in C#. It can also pack the DLL files with the EXE, creating a
single EXE file:
http://madebits.com/netz/index.php Tag: Free components Tag: 108676
CPU load of process started from .Net Process class is low
Hello,
is here anybody who can tell me why process started with Process class
has less CPU time that same process started from command line? Most
strange thing is that when I use Process class to start batch file,
which starts that process, it works faster.
BR Tag: Free components Tag: 108674
Smart Client Problem
Hi,
I have developed C# Windows application. I thought of deploying this
application in the webserver and access the application like SmartCLient
model.
I have given IIS permissions. I have written small application which will
access the main application using URL.
I am gettin the login screen of the main application, entered the user name
and password, clicked on teh OK, when i click on OK, it will check the
app.config file and will connect to the database and will get the MDI screen
to Client PC. Here i am getting the Exception. I am unable to catch this
exception also. WHen i write MessageBox.Show, it is not displaying the
exception, please help me in this.
Thanks in advance
Satish Tag: Free components Tag: 108673
Using TcpClient with Modem
Hi everybody,
I am still learning how sockets, TcpClient and TcpListener work, in order
that both sides to send and receive data, both sides must have a socket or
TcpListener and a TcpListener right? Is there a possible way to say just have
a client side TcpClient application to send a message to remote server like
sending a text file?
Do TcpClient requires a Internet connection to connect say to remote
server? So, to connect to a VPN network(remote server), I need to establish
internet connection like using RAS. Right? How do you programatically create
connection using a local USB port with a GPRS modem? Using Sockets or
TCPClient will be enough to do that? Please provide me with info on these
questions.
Is there anybody knows how to do this? Thanks.
den2005
--
MCP Year 2005, Philippines Tag: Free components Tag: 108671
MSN chat integration
i dont want to have my own chat application but instead integrate msn chat
with my application, are there any API exposed for it??? Tag: Free components Tag: 108668
Why Assembly.LoadWithPartialName is obsolete?
Hello,
Does anybody know why the "Assembly.LoadWithPartialName" is obsolete?
It seems that the Load method does not have an equivalent replacement for
it.
--
Best Regards,
W. Jordan Tag: Free components Tag: 108659
framework for linux????
Hi all,
Is there a framework for linux?
Is it possible to run a .net application on a linux platform?
thank you very much
mi... Tag: Free components Tag: 108655
testing a program is running
I'm writing my installer which, of course, is a win32 app (no .NET)
I would like to test tthe program is already running (in case of
reinstall/upgrade) and prompt the user to stop the application.
How do I do that?
Basically I would like somthing like Process.GetProcessByName() but with
win32 calls.
Any idea? Tag: Free components Tag: 108654
WaitCursor / hourglass in custom printpreview dialog
Hi,
I have created a simple custom PrintPreviewDialog consisting of a simple
standard PrintPreviewControl (.NET 1.1) on a WindowsForm with a few buttons
(for printing, zooming, etc.). It is working fine, except for that I cannot
figure out how display the waitcursor / hourglass while the preview is
preparing to show the document *and then go back to the default cursor when
the document is displayed*. Turning on the waitcursor is easy, but what
event should I hook into to turn it off??
What happens when I preview a document that is about 50 pages long is that
you get the blank form on the screen and then nothing happens for maybe 40
seconds and then you get a "Generating Preview" message and then the
document is displayed. It is during the initial 40 seconds that I need an
hourglass or something to let the users know that something is happening in
the background.
Here are some snippets of what I am doing currently:
// Constructor:
public PreviewDialog(System.Drawing.Printing.PrintDocument printDocument,
int zoom)
{
InitializeComponent();
_printDocument = printDocument;
_zoom = zoom;
}
private void PreviewDialog_Load(object sender, System.EventArgs e)
{
this.Cursor = Cursors.WaitCursor;
Initialize();
//this.Cursor = Cursors.Default; // This gets hit instantly, so you
never see an hourglass.
}
private void Initialize()
{
uxPrintPreview.Anchor = AnchorStyles.Bottom | AnchorStyles.Top |
AnchorStyles.Left | AnchorStyles.Right;
uxPrintPreview.Zoom = zoom;
this.WindowState = FormWindowState.Maximized;
uxPrintPreview.Document = printDocument1 = printDocument;
}
// The calling code:
using (PreviewDialog form = new PreviewDialog(c1Report1.Document))
{
form.ShowDialog(this);
}
If there was an event like LastPageFinished or DocumentRendered or similar
in the PrintPreviewControl, I would be home free, but I cannot find anything
like that.
Any help on this would be greatly appreciated.
Thanks,
Lars Tag: Free components Tag: 108648
Work Flow
Hi All,
Is there any open source code available for workflow engine in C#, VB .Net
framework.
Regards
- Atul Sureka Tag: Free components Tag: 108647
How to store objects created with C# in database in .NET Framework
I want to store the objects that i create in run time in database. In a way
that, for a product a create an object from a class written with C#, define
its properties and functions that it has, and want to store it in a database
(SQL Server 2K). I want the columns to be created and filled dynamically when
an object is inserted in db (Just like in J2EE, which is called i think
relational mapping, or something like this).
How can I do that? Tag: Free components Tag: 108641
How to store C# objects in DB
I want to store objects that i create programmatically in C#, like in J2EE
(which is callad i think relational mapping or sometihng like this). I want
to create objects that i use for my enterprise applications and store them in
database after execution. And I want the columns and rows related to my
objects to be created and filled automatically.
How can i do that. Thanks? Tag: Free components Tag: 108640
.NET Remoting to COM
Hello,
I have a .NET application where I want to be able to access COM objects on a
remote server (theses objects are the base for a web appliation we are
running).
I've been looking on the net for an easy example, or at the very least some
documentation that would make tell me how to do it (if at all possible). So
if anyone has any idea on how this could (or coudn't) be done, or any cue on
where to look and for what, I would strongly appreciate.
Many thank's in advance.
Eric Tag: Free components Tag: 108637
installed 2.0.50727 now I get a sql express error message
I now get the following error message after copying an asp.net application to
the deployment web server. I don't have SQLExpress or any version of SQL
2005 installed. I found the "LocalSQLServer" connection string in the
machine.config, changed that to look at a SQL 2000 database, but the error
still comes up.
An error has occurred while establishing a connection to the server. When
connecting to SQL Server 2005, this failure may be caused by the fact that
under the default settings SQL Server does not allow remote connections.
(provider: Named Pipes Provider, error: 40 - Could not open a connection to
SQL Server)
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: An error has occurred
while establishing a connection to the server. When connecting to SQL Server
2005, this failure may be caused by the fact that under the default settings
SQL Server does not allow remote connections. (provider: Named Pipes
Provider, error: 40 - Could not open a connection to SQL Server)
Source Error:
An unhandled exception was generated during the execution of the current web
request. Information regarding the origin and location of the exception can
be identified using the exception stack trace below.
Stack Trace:
[SqlException (0x80131904): An error has occurred while establishing a
connection to the server. When connecting to SQL Server 2005, this failure
may be caused by the fact that under the default settings SQL Server does not
allow remote connections. (provider: Named Pipes Provider, error: 40 - Could
not open a connection to SQL Server)]
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException
exception, Boolean breakConnection) +734995
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject
stateObj) +188
System.Data.SqlClient.TdsParser.Connect(Boolean& useFailoverPartner,
Boolean& failoverDemandDone, String host, String failoverPartner, String
protocol, SqlInternalConnectionTds connHandler, Int64 timerExpire, Boolean
encrypt, Boolean trustServerCert, Boolean integratedSecurity, SqlConnection
owningObject, Boolean aliasLookup) +820
System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection
owningObject, SqlConnectionString connectionOptions, String newPassword,
Boolean redirectedUserInstance) +628
System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity
identity, SqlConnectionString connectionOptions, Object providerInfo, String
newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) +170
System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions
options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection
owningConnection) +359
System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options) +28
System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection
owningObject) +424
System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection
owningObject) +66
System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection
owningObject) +496
System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection
owningConnection) +82
System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection
outerConnection, DbConnectionFactory connectionFactory) +105
System.Data.SqlClient.SqlConnection.Open() +111
System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset,
DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable,
IDbCommand command, CommandBehavior behavior) +121
System.Data.Common.DbDataAdapter.Fill(DataTable[] dataTables, Int32
startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior behavior)
+162
System.Data.Common.DbDataAdapter.Fill(DataTable dataTable) +107
TIA,
Dave Tag: Free components Tag: 108636
mscorsvw x64 OS freeze When Idle
Hello,
I am running XP64 SP 1. I had VS2003 installed. When I tried to install
VS2005 professional my machine froze on the framework 2.0 install. I
rebooted and tried again. Same thing. I disabled my Antivirus and tried
again. Froze on the same spot.
I uninstalled VS2003 and framework 1.1, disabled my Antivirus and tried to
install framework 2.0 from the MS update website. The system froze. Once
rebooted, "Add or Remove Programs" showed that the install was complete. I
rebooted, disabled my Antivirus and then tried to install VS 2005. It
worked.
Unfortunately every time I leave my system idle for 5 to 10 minutes it
freezes up again. I opened my task manager and let it idle and every time it
freezes mscorsvw.exe is on the top of the CPU order. I did some research
and found this article.
http://blogs.msdn.com/davidnotario/archive/2005/04/27/412838.aspx
I tried the:
ngen.exe executequeueditems
It ran, reported some errors that I missed durning the scroll by and then
locked up. I have tried it again and it locks up each time at:
Executing
C:\windows\microsoft.net\framework\v2.0.0.0,culture=neutral,publictoken=b77a5c561934eo8911 /nodependencies /nologo
Least that the way I read my bad hand writing.
Any ideas on how to fix it?
Thanks in advance
Mark Tag: Free components Tag: 108634
upgrading to .NET 2.0 woes
hello ,
I'm upgrading c++ files in which the source is available that has a
managed wrapper to a non-managed dll. It was .NET 1.1 now I want .NET
2.0
I made some changes and I now get some warnings when compiling. I get
no errors.
Running this dll from my C# app returns the following exception:
{"Strong name validation failed. (Exception from HRESULT: 0x8013141A)"}
referring to the data:
{System.Collections.ListDictionaryInternal}
Now as far as I know .NET 2.0 does not contain
"System.Collections.ListDictionaryInternal". I'de like to fix my c++
file to point to the new
"System.Collections.Specialized.ListDictionary" but I can't even find
where it is trying to do this :( Searching the project for
"ListDictionary" did not return anything.
Any hints?
V. (c++ ultra-noob) Tag: Free components Tag: 108631
assembly name or one of its dependencies was not found
Hey Everyone,
I have run into a problem with asp.net
I have a web page default.aspx that posts to itself. On post, I call a
WebService to validate uername and password.
In the catch block of the WebSerive call, I am getting the attached
error. I have been researching this error for about two days and have
tried adding the ASP.NET and NETWORK SERVICE users to the administrator
group with full permissions over C:\WINDOWS and it's children as most
of the research I did pointed to that issue.
I have also installed the XMLPrecompiler solution to see if there are
any issues with serialization, but everything checks out fin there as
well.
Lastly, I verified that I was running .NET 1.1.X as some research said
that may be an issue as well. I would appreicate any help or any
suggestions.
-MW
ERROR TEXT:
at
System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage
message, WebResponse response, Stream responseStream, Boolean
asyncCall) at
System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String
methodName, Object[] parameters) at
CUSTOM METHOD DECLARATION
System.Web.Services.Protocols.SoapException: Server was unable to
process request. --> File or assembly name oaayvpwc.dll, or one of its
dependencies, was not found. at
System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage
message, WebResponse response, Stream responseStream, Boolean
asyncCall) at
System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String
methodName, Object[] parameters)
CUSTOM METHOD DECLARATION
Server was unable to process request. --> File or assembly name
oaayvpwc.dll, or one of its dependencies, was not found. Tag: Free components Tag: 108630
Refreshing TreeView after Editing a Label
Here's the problem. I have a TreeView that is essentially a listing of
directories and files. If you right-click on a directory then a
context menu comes up and one of the options is "New Folder", when the
user clicks that it expands the current node, creates and add's a child
node, then calls BeginEdit() on the child node.
I have written a custom class that implements IComparer to sort on
rules that I have defined. The problem comes in the fact that
BeginEdit() appears to be an async call, and as far as I can tell,
there's no event that gets fired to let me know when it is done so that
I can then call Sort() on the TreeView. There is an 'AfterLabelEdit'
event on the TreeView, but it appears that the actual label on the node
isn't changed until after that event is finished firing. I've tried
manually setting the text of the node in an event handler for that
event, but it causes the TreeView to do wierd things (like the node is
still editable after I finished editing it, and if this is the second
or so folder I've created, the previous one I create is being
reassigned the same name as the one I created. If anyone can help me,
I'd appreciate it.
Code:
================================================
private void contextMenuFolder_Click(object sender, EventArgs e)
{
TreeNode newFolder = new TreeNode("", FOLDER_CLOSED,
FOLDER_OPEN);
tvwReports.SelectedNode.Nodes.Add(newFolder);
tvwReports.SelectedNode.Expand();
CatalogItem item = new CatalogItem();
item.Type = ItemTypeEnum.Folder;
newFolder.Tag = item;
newFolder.BeginEdit();
}
private void tvwReports_BeforeLabelEdit(object sender,
NodeLabelEditEventArgs e)
{
if (e.Node.Tag != null)
{
if ((e.Node.Tag as CatalogItem).Type !=
ItemTypeEnum.Folder)
e.CancelEdit = true;
else
e.CancelEdit = false;
}
else
e.CancelEdit = true;
}
private void tvwReports_AfterLabelEdit(object sender,
NodeLabelEditEventArgs e)
{
this.Cursor = Cursors.WaitCursor;
string fullPath =
e.Node.FullPath.Substring(e.Node.FullPath.IndexOf('/'));
if ((e.Node.Tag as CatalogItem).Name == null)
{
if (e.Label == null || e.Label == "")
//this is a new folder and no name was given,
delete the node
e.Node.Remove();
else
{
//get path as relative to the webservice
fullPath += e.Label;
//new folder node, need to call webservice to add
CatalogItemManagement.CatalogItemManager.AddFolder(fullPath);
e.Node.Tag =
CatalogItemManagement.CatalogItemManager.GetCatalogItem(fullPath);
}
}
else if ((e.Node.Tag as CatalogItem).Name != e.Label)
{
if (e.Label == null || e.Label == "")
//the label was left blank, set it back to what it
was before
e.CancelEdit = true;
else
{
//node already existed, but folder name has
changed, need to update
CatalogItemManagement.CatalogItemManager.MoveCatalogItem(fullPath,
fullPath.Replace(e.Node.Text, e.Label));
}
}
this.Cursor = Cursors.Default;
}
================================================
I am using Visual Studio 2005 (with .NET 2.0, of course) Tag: Free components Tag: 108620
Nullable<int>, implementing GetHashCode, and thread safety
The VS2005 documentation for Object.GetHashCode has three notes to
implementors:
*blockquote*
If two objects of the same type represent the same value, the hash function
must return the same constant value for either object.
For the best performance, a hash function must generate a random
distribution for all input.
The hash function must return exactly the same value regardless of any
changes that are made to the object.
*/blockquote*
So in a reference type that isn't immutable satisfying the third requirement
seems to require caching the hash code the first time it's queried for. This
seems like a good place for Nullable<int>.
However, if there's a competing requirement for the reference type to be
thread-safe, the cached hash code needs to be initially assigned in a thread
safe manner. To avoid the thread safety problems with double checked locking,
there will be a locking cost associated with initially creating and caching
the hash code. To minimize the cost, and since the hash code will be
int-sized, it'd be nice to take advantage of the System.Threading.Interlocked
class's methods.
Hmm, but Interlocked.CompareExchange can't handle the following:
Nullable<int> alpha = null;
int value = 1;
Interlocked.CompareExchange(alpha,value,null);
Rats. The nullable type would have seemed cleaner, but boxing an int into an
object (below) still works.
Is this the best way to go?
How bad would the overhead of locking a private instance field and using a
nullable type be by comparison?
Is there something obvious with Nullable<int> that I'm missing that would
support this?
Should Interlocked get overrides to handle Nullable<T>?
Could such overrides avoid the same overhead that locking a private instance
field would face?
class Triple<T1, T2, T3>
{
private Object hashCode;
private T1 first;
private T2 second;
private T3 third;
//...
public override int GetHashCode(){
if (this.hashCode == null){
int firstHash = (!Object.ReferenceEquals(this.first,null)) ?
this.first.GetHashCode() : 0;
int secondHash = (!Object.ReferenceEquals(this.second,null)) ?
this.second.GetHashCode() : 0;
int thirdHash = (!Object.ReferenceEquals(this.third,null)) ?
this.third.GetHashCode() : 0;
Interlocked.CompareExchange(ref this.hashCode,
(Object)(firstHash ^ secondHash ^ thirdHash), null);
}
return (int) this.hashCode;
}
//...
} Tag: Free components Tag: 108617
Embed windows media player and possibly others in .net app?
I have a list of media files to choose from in the app. Right now
clicking on it will launch it using System.Diagnostics.Process.Start to
launch whatever appropriate application for that particular file. Since
I know the extension of the file, can I embed media player in the app
instead of having media player popped up and run separately, just like
embedding the media player in the web page with certain functionality
show? Tag: Free components Tag: 108615
How to add right click menu
Tool: Visual Studio 2005
I have a custom photo library application previously written in VS 6.
Basically it has
1) DriveListBox, DirListBox, FileListBox, all listed as
Microsof.VisualBasic.Compatibility.xxx
2) PictureBox inside a Panel (for auto showing scroll bars when photo
exceeds viewable area).
3) Buttons under FileListBox to Rename, Delete, etc file.
I'm thinking there must be something equivalent to Explorer that allows
you to single click to rename, right click with a bunch of options
(Rename, Delete, Cut, Paste, etc) that I can replace the FileListBox
with. If not, then I'd like to make it so that right click on a
selected file would prompt a context menu with a few basic options.
Thanks. Tag: Free components Tag: 108608
setting envrionment variable in C# and access it within native C++
We are having difficulties getting environment variable within native DLL
written in C++ which is loaded by C# .NET assembly, the env var is set by the
.NET assembly.
We have an existing C++ application, and want to access it within C#. So we
wrote Managed C++ wrapper which access the native C++ DLL. The Managed C++
wrapper is compiled as .NET assembly that C# can access.
The native C++ DLL need to have an environment variable set to work
properly. So within the C#, we use:
[DllImport("Kernel32.dll")]
public static extern int SetEnvironmentVariable( string name , string
value );
to set the env var.
But within the native C++ DLL, it will fail when trying to do "getenv()",
with error:
Object reference not set to an instance of an object.
1. If we make the C# application as console application and set env var in
the console before start the C# application, it works. But we can't make the
C# app a console app.
2. If we execute within the C# application a .bat file which prints out the
env var, it shows that the env var is set.
Looks that the native C++ DLL can't getenv() on the env var set within the
C# app.
Any solutions for this?
Thanks a lot. Tag: Free components Tag: 108605
programmatic to ftp virtual directories
programmatic to ftp virtual directories
when i connect to an ftp server and i only have access to a few of the ftp
virtual directories, do i just change directory to them after connecting and
having credentials authorized? is there some special protocol for changing
directories to authorized virtiual directories? Tag: Free components Tag: 108604
programmatic to ftp virtual directories
programmatic to ftp virtual directories
when i connect to an ftp server and i only have access to a few of the ftp
virtual directories, do i just change directory to them after connecting and
having credentials authorized? is there some special protocol for changing
directories to authorized virtiual directories? Tag: Free components Tag: 108603
ASP Windows Service or Console based application
Hi all,
I am confused as to what kind of application to develop. I have to create an
application thats like a "Engine" which continously monitors a DB or
whatever. It has to work even if the user logoff as this engine feeds some
other application.
I tried creating a Windows service that runs continously but the status
shows "Starting" and i cant "Stop" or "Pause" and was suggested by one
BravesCharm that "Status does not change as the service never notifies the
SCM that everything started OK" which makes sense.
Is there a way for windows service to start some other application? is yes
then how can i stop it from this windows service?
Please do give me suggestions on how to achieve this.
Thanks,
Stephen Tag: Free components Tag: 108601
Clickonce install from CD
Hi,
I generated the deployment files into a local directory with specified
installation URL.
My prolbems:
- If there is an internet connection on the client machine, it skips the
files on the local hard drive, immediately start downloading from the web.
- if there is no internet connection, the setup.exe fails (which is the
startup program from a CD), but the application icon installs the software
well.
I implemented a custom async update. When I call the CheckUpdateAsync method
I have got an exception in the Application.ThreadException event, not in the
AsyncCompleted event as the MSDN says (in the e.Error)...
Why?
Thanks.
lelez
------------
Here it is the code:
try
{
ApplicationDeployment dep =
ApplicationDeployment.CurrentDeployment;
dep.CheckForUpdateCompleted += checkHandler;
dep.CheckForUpdateAsync();
}
catch (System.Net.WebException)
{
// never runs!
System.Windows.Forms.MessageBox.Show("There is no internet
connection.");
}
catch (Exception ex)
{
xxxx.Common.Util.Logger.LogException(ex);
}
Here it is the handler:
private static void dep_CheckCompleted(object sender,
CheckForUpdateCompletedEventArgs e)
{
if (e.Error is System.Net.WebException)
{
System.Windows.Forms.MessageBox.Show("There is no internet
connection.");
return;
}
ApplicationDeployment dep =
ApplicationDeployment.CurrentDeployment;
dep.CheckForUpdateCompleted -= checkHandler;
try
{
if (e.UpdateAvailable)
{
ContinueQuestionEventArgs ce = new
ContinueQuestionEventArgs(e.AvailableVersion.ToString());
// Ask the user about continue...
if (updateIsAvailable != null)
updateIsAvailable(null, ce);
if (ce.Continue)
{
dep.UpdateCompleted += updateHandler;
dep.UpdateAsync();
}
}
}
catch(InvalidOperationException ex)
{
xxxxx.Common.Util.Logger.LogException(ex);
}
} // dep_CheckCompleted...
--
-----------------------------------
http://www.lelez.hu
ICQ: 177465172 Tag: Free components Tag: 108600
Caching architecture question.
I am thinking about using Caching application block in my web
application, for the performance reasons.
My ideal sitiuation would be if i could plug in the application block
between my Persistence layer and database, so that objects are created
from the cache and cost of CRUd operation can be avoided....
the problem each object is not having a unique key, and caching
application block does not provides any typed cache functionality, for
example if i store a product object wtih uid 1 and a customer object
with uid 1 then it would overwrite the product object,
Iam thinking about creating a multiple cache managers according to the
type of object, and keep all those cache managers in a super cache...
in that case would the scavenger clean up caches inside a cachemanager
object ?
any comments Tag: Free components Tag: 108595
Program for my scanner
This is a long shot, but here goes...
I have an HP scanner that came with some software I don't like at all. I
would like to write my own dotnet program. What is required? I suppose I
would need some sort of component (HP proprietary) to get started. Would HP
make such a component accessible for us? What can I do?
Thanks. Tag: Free components Tag: 108593
GDI leaks?
Hello all,
I've just found the issue that really scares me. It seems that ListView
doesn't release some GDI objects. Here you are steps to reproduce the
problem:
1. Run Task Manager
2. View->Select Columns
3. Check "GDI Objects", press OK
4. Run Visual Studio 2k3
5. Create new Window Forms application
6. Put into the form "ListView" and enter 5 items.
7. Run Application
8. Force application to refresh (e.g. move another window above this
application)
You will see that GDI objects increase really fast. The same situation
with Add/Remove items, GDI objects still increas. I've noticed that I
can increase it number even till 10k and after that application starts
to glitch.
It seems that the problem can be solved after:
GC.Colelct();
But this is *really* bad solution which significant impacts to the
performance of application.
Any ideas?
Thank you,
John Tag: Free components Tag: 108591
Web Config and regular string literal
I am trying to keep the body of an email message in the web.config, something
like
"We have received ..... blah.. blah.. \n Thank you, \n ... some whitty
closing line".
Anyway, when I read this it is always coming back as a verbatim string
literal and the email contains the escape chars (\n). How can I make this a
regular string literal so that the email body will recognize the escape
characters?
Thank you Tag: Free components Tag: 108590
RegionInfo.ThreeLetterISORegionName returns TwoLetterIsoCode for B
Hi all,
I need to get the ISO-3166 code for BOSNIA AND HERZEGOVINA.
What I am trying is
1) RegionInfo ri = new RegionInfo(5146); ==> works fine and gets RegionInfo
2) ri.ThreeLetterISORegionName ==> Output "BA". Expected "BIH".
But I only get "BA" - not "BIH".
Any help greatly appreciated
I have noticed that BA/BIH is not listed in
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemglobalizationregioninfoclasstopic.asp
Might this be the problem?
I have also read about synthetic cultures
http://blogs.msdn.com/shawnste/archive/2005/12/06/500675.aspx
But anyway, BIH is a valid code found in ISO-3166.
Any ideas how to get it via RegionInfo?
Thanks,
DPOMT Tag: Free components Tag: 108589
Dynamically import fusion.dll
I'd like to dynamically import methods from the fusion library (fusion.dll).
However, if I just do a straight [DllImport(blah)], I can't guarantee that I
get the .Net 2 runtime version.
I've found that the unmanaged method LoadLibraryShim in mscoree.dll will
return a module handle to the latest runtime version, the thing I can't
figure out is how to then use this handle to invoke methods on the library
from C#.
Any hints gratefully received! Tag: Free components Tag: 108588
System.Threading.Timer & W2K3 problem
Hi all,
I've implemented a Windows service application with c# and .NET Framework
1.1.
The service starts 10 timers of type System.Threading.Timer.
The service runs as expected on Windows XP and 2000 Professional.
On the Windows 2003 Server + SP1 (Intel Xeon) some of the timers stop firing
after a short period of time.
No exceptions are thrown and no deadlocks occur.
Do you have any resolution?
Thanks,
Mircea Tag: Free components Tag: 108581
automatic Time conversion ?
Hello all,
I am writting a client application that asks a DataSet from a server
(WebService) and displays it locally in a DataGridView. The DataSet has a
DateTime column. The problem is that the server and the client work in
different time zones, and somewhere in the client the time conversion is made
(added / substracted 1 hour). So in my grid I see different hours.
How can I stop that ?
Basically, I need to ignore this diference, but I can't find a way.
Please help. Tag: Free components Tag: 108577
Run exe on LAN machine
Please tell me how i can run .exe file on a LAN machine. I have
administrative permissions. I am using C#.NET Tag: Free components Tag: 108571
Hidden Attribute on file affects security?
Hi ---
I tried to write an application that uses a config file. When I set the
Hidden attribute on the config file, I found that my application was no
longer able to write (System.IO.File.WriteAllText as well as
System.IO.File.StreamWriter), and also not able to delete
(System.IO.File.Delete), the file. I get an access denied error.
However my application can remove the Hidden attribute, after which writing
and deleting work properly.
Is this expected behavior? If so, can someone point me to the documentation
that explains the relationship between hiddenness and file access?
thanks,
denise Tag: Free components Tag: 108563
Does Framework 2.0 trash COM for everyone else ?
We are running Server 2003 for our critical server applications. We
have been updating a number of core software pieces to VS2005 /
Framework 2.0. This software is installed and pretty much working as it
should.
The PERPLEXING issue to me is that I have antique VB6 COM components
that are failing after adding Framework 2.0 to this server. Usually when
the component is done after a lengthy process, and is returning to the
caller. The VB6 component seems to have completed successfully, but the
exception "Object variable or With block variable not set" is being
thrown to the calling script.
I have a VB6 test application which invokes the same VB6 COM component,
and it also fails with the same error, at this server. We are talking
about software that has been in there doing its job for years.
Wanting to see it fail first hand I ran the test application on a
development computer, W2K, and it of course runs fine.
Besides a few isolated and unrelated VS2005 applications of our own, the
only thing new on this computer is Framework 2.0 redistributable
installation. I have to be suspicious that this has some how trashed COM
for others. Tag: Free components Tag: 108557
vs2003 and .Net 2
Hello,
I have vs2003 installed in my computer, I want to try .Net 2, can I install
.Net 2 and still be able to use vs2003 and .Net 1? Please advice Tag: Free components Tag: 108551
cookie problem
Greetings...
I need desperate help with my problem.
I guess the solution is related in some way with the cookies getting
lost in the authentication process working with some web servers.
Appreciate any help you could provide.
I've created an application that does the authentication process
using forms. I've succeed to install it in a lot of web servers and
it works perfect. But, and here is the problem, in some of the web
servers this is what happens:
Starting the application the user has to follow the authentication
process. If the user fails to enter the password, the server
communicates him that either the password or the user name is
incorrect. At this point, the process works fine. The problem starts
when the user follow the authentication process correctly (user name
and password are correct), after this, the system fails to continue to
the next page, the user is sent back to the authentication page (like
he was trying to violate the security using the URL).
This problem happens when a user is trying to do the authentication
process in a client machine; it doesn't happen if the user is in the
server machine.
I've done some research and these are the results:
As the application works fine in most of the servers I've installed
it, it shouldn't be an application problem.
As the application gives the user an answer when either the user name
or the password is incorrect, the server is responding correctly.
As the application works fine if the user is in the server machine,
installation or database problems are discarded.
I've been tracking the cookies and this is what happens: If the user
is working directly on the server machine, the system creates the
cookies and everything works fine. But, if the user is working on any
client machine the cookie never arrives.
The problem is not on the client machines as if I connect them to
another server, the cookie is created and the application works fine.
The user is redirected to the authentication page because the cookie
gets lost (Again: The client machines works fine connected to other
servers) and he loses his credentials.
Searching through the web I've found that there is a problem with the
server name when it has characters like "_", but this is not my
case. I've tried names like:
Server/MyApp/Authentication.aspx
192.168.1.100/MyApp/Authentication.aspx
OtherName/MyApp/Authenticacion.aspx
But none of them works.
I hope I've been clear enough with my explanation.
Thanks in advance for any help you can give me.
PD: The application has been developed using C# in VS .NET. Tag: Free components Tag: 108549
"Directory Service error"
I have a problem with a .NET 1.0 system and Azman.
The error message I receive is
"A Directory Service error has occured".
The weird thing is that the error is not consistent,
it can occur for a day, then weeks can pass withouth the error to
occur and then it occurs again, so we haven't been able to
estimate when it present.
Can somebody help me with it? Tag: Free components Tag: 108548
SMTP and CDO.Message Object error
This is a multi-part message in MIME format.
------=_NextPart_000_0011_01C60176.1A6EDE40
Content-Type: text/plain;
charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable
In my Win app I found that using the SMTP object doesn't release =
resources after closing the application. During testing I have to open =
and close the app many times and I found that after about three times it =
locks up when I call the Send() method and returns the error "Could not =
access CDO.Message Object". I found that if I create a new Win App and =
copy and paste the code into it, then it runs fine for the first couple =
of times and then starts returning that error. I also noted that I can =
send as many email messages as I want and they all get sent with no =
error as long as I don't close the program. Unfortunately, not closing =
the program isn't possible and I'm creating new apps constantly as I =
test my code.
I have two theories. The first being that the program doesn't release =
SMTP resources and after a couple times running all the resources are =
used up. But if that's the case, then why does creating a new app always =
work? My second theory is that somehow SMTP holds a pointer the =
application calling it and it only lets each app have a couple pointers =
allocated to it. That's why new apps always work but then get locked out =
after a couple tests.
I tried using garbage collection to free resources, but the SMTP object =
is a WinNT object and I can't instantiate it directly. So garbage =
collection hasn't helped solve the problem. =20
After doing more testing, I found that if I leave the SMTP.ServerName =
empty, then it works everytime. The problem with this is that since I'm =
not specifying the corporate email server, then this isn't a reliable =
method for a production system. So this isn't a practical fix.
Any ideas?
Here is my test code:
static void Main()=20
{
Application.Run(new Form1());
System.GC.Collect();
}
private void Form1_Load(object sender, System.EventArgs e)
{
Send(person@email.com", person2@Email.com", "","test 2", "hello");
}
public void Send(string From, string To, string CC, string Subject, =
string Body)
{
System.Web.Mail.MailMessage Email=3Dnew MailMessage();
Email.From=3DFrom;
Email.To=3DTo;
Email.Cc=3DCC;
Email.Subject=3DSubject;
Email.Body=3DBody;
Send(Email);
Email=3Dnull;
}
public void Send(System.Web.Mail.MailMessage Email)
{
SmtpMail.SmtpServer =3D "smtp.ucsd.edu";
try=20
{
SmtpMail.Send(Email);
}
catch(Exception e)
{
string x;
x=3De.Message;
MessageBox.Show(x);
}
}
private void Form1_Closed(object sender, System.EventArgs e)
{
System.GC.Collect();
}
------=_NextPart_000_0011_01C60176.1A6EDE40
Content-Type: text/html;
charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Dwindows-1252">
<META content=3D"MSHTML 6.00.2900.2769" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV><FONT face=3DArial size=3D2>In my Win app I found that using the =
SMTP object=20
doesn't release resources after closing the application. During testing =
I have=20
to open and close the app many times and I found that after about three =
times it=20
locks up when I call the Send() method and returns the error "Could not =
access=20
CDO.Message Object". I found that if I create a new Win App and copy and =
paste=20
the code into it, then it runs fine for the first couple of times and =
then=20
starts returning that error. I also noted that I can send as many email =
messages=20
as I want and they all get sent with no error as long as I don't close =
the=20
program. Unfortunately, not closing the program isn't possible =
and I'm=20
creating new apps constantly as I test my code.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>I have two theories. The first =
being that=20
the program doesn't release SMTP resources and after a couple times =
running=20
all the resources are used up. But if that's the case, then why does =
creating a=20
new app always work? My second theory is that somehow SMTP holds a =
pointer=20
the application calling it and it only lets each app have a =
couple=20
pointers allocated to it. That's why new apps always work but then=20
get locked out after a couple tests.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>I tried using garbage collection to =
free resources,=20
but the SMTP object is a WinNT object and I can't instantiate it=20
directly. So garbage collection hasn't helped solve the problem.=20
</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>After doing more testing, I found that =
if I leave=20
the SMTP.ServerName empty, then it works everytime. The problem with =
this is=20
that since I'm not specifying the corporate email server, then this =
isn't a=20
reliable method for a production system. So this isn't a practical=20
fix.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Any ideas?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>Here is my test code:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>static void Main() </FONT></DIV>
<DIV><FONT face=3DArial size=3D2>{</FONT></DIV>
<DIV><FONT face=3DArial size=3D2> Application.Run(new=20
Form1());</FONT></DIV>
<DIV><FONT face=3DArial size=3D2> =20
System.GC.Collect();</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>}</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>private void Form1_Load(object sender,=20
System.EventArgs e)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>{</FONT></DIV>
<DIV><FONT face=3DArial size=3D2> Send(<A=20
href=3D'mailto:person@email.com", person2@Email.com", =
"","test'>person@email.com",=20
<A href=3D"mailto:person2@Email.com">person2@Email.com</A>", =
"","test</A> 2",=20
"hello");</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>}</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>public void Send(string From, string =
To, string CC,=20
string Subject, string Body)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>{</FONT></DIV>
<DIV><FONT face=3DArial size=3D2> =
System.Web.Mail.MailMessage=20
Email=3Dnew MailMessage();</FONT></DIV>
<DIV><FONT face=3DArial size=3D2> =
Email.From=3DFrom;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2> =
Email.To=3DTo;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2> =
Email.Cc=3DCC;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2> =20
Email.Subject=3DSubject;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2> =
Email.Body=3DBody;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2> =
Send(Email);</FONT></DIV>
<DIV><FONT face=3DArial size=3D2> =
Email=3Dnull;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>}</FONT></DIV>
<DIV><FONT face=3DArial size=3D2><BR>public void =
Send(System.Web.Mail.MailMessage=20
Email)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>{</FONT></DIV>
<DIV><FONT face=3DArial size=3D2> SmtpMail.SmtpServer =
=3D=20
"smtp.ucsd.edu";</FONT></DIV>
<DIV><FONT face=3DArial size=3D2> try </FONT></DIV>
<DIV><FONT face=3DArial size=3D2> {</FONT></DIV>
<DIV><FONT face=3DArial size=3D2> =20
SmtpMail.Send(Email);</FONT></DIV>
<DIV><FONT face=3DArial size=3D2> }</FONT></DIV>
<DIV><FONT face=3DArial><FONT size=3D2><FONT face=3DArial=20
size=3D2></FONT></FONT></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2> catch(Exception =
e)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2> {</FONT></DIV>
<DIV><FONT face=3DArial size=3D2> =
string=20
x;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2> =20
x=3De.Message;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2> =20
MessageBox.Show(x);</FONT></DIV>
<DIV><FONT face=3DArial size=3D2> }</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>}</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV>
<DIV><FONT face=3DArial size=3D2>private void Form1_Closed(object =
sender,=20
System.EventArgs e)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>{</FONT></DIV>
<DIV><FONT face=3DArial size=3D2> =20
System.GC.Collect();</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>}</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV></DIV></BODY></HTML>
------=_NextPart_000_0011_01C60176.1A6EDE40-- Tag: Free components Tag: 108547
Windows Service using ASP .NET
Hi,
I created a windows service to insert data into a DB,
First time I tired to insert data on_start() it starts perfectly but the
insert is for a single entry into the DB
checked Services and it highlights the stop button
Now I wanted it add data continously so i put a while loop and to exit if it
errors, i deployed and click "start" on services, this time it took a long
time to do start the service but the status was still "Starting" instead of
"started"
Data entry into the DB was normal, no error logs, created a new entry in
"eventvwr.msc"
the Problem: I cannot stop the service, I cant kill it.... what am I doing
wrong?
Please advice,
Stephen Tag: Free components Tag: 108543
Windows 98 and .Net Service
I knew it would happen. I have a large who customer wants to run our Windows
Service App on a Win98 Machine...
Is it possible to run a Windows Service developed in .Net on Win98?
If so, do I need to create a Service Control App to Start and Stop the
Service? If not, how do I start it (net start ServiceName).
Do I need to Install the Service using InstallUtil.exe?
Also how can I debug the app on the win98 machine?
Thanks for your insights. If you can direct me to a discussion, that would
be great! Tag: Free components Tag: 108537
Hi
who can advice me a good web site with free
.NET components, it will be great if there will be cources also
although none of them has cources (what ever it is..) they all have source
code!
"Fox" <mail@job.am> wrote in message
news:%23SY1JSKBGHA.3352@TK2MSFTNGP09.phx.gbl...
> Hi
> who can advice me a good web site with free
> .NET components, it will be great if there will be cources also
>
> Thank you.
>
>
>
"Fox" <mail@job.am> wrote in message
news:%23SY1JSKBGHA.3352@TK2MSFTNGP09.phx.gbl...
Hi
who can advice me a good web site with free
.NET components, it will be great if there will be cources also
"Fox" <mail@job.am> wrote in message
news:%23SY1JSKBGHA.3352@TK2MSFTNGP09.phx.gbl...
> Hi
> who can advice me a good web site with free
> .NET components, it will be great if there will be cources also
>
> Thank you.
>
>
>