|
Yes we do have a VPN.
M.Sendilkumar
TVS Infotech Ltd
Chennai
|
|
|
|
|
Can any one help me to understand 'What is 'Thread Safe' in .Net?
Almost all class explanation of MSDN help having this word 'Thread Safe'.
Please help me to understand this.!
M.Sendilkumar
TVS Infotech Ltd
Chennai.
|
|
|
|
|
When you have more than one thread accessing the same object then problems can arise, mostly due to the scheduling performed by the OS.
One thread can start modifying the object and before it's done another thread gets permission to run and will work on inconsistent data.
In this respect, such an object would be not thread safe.
Because implementing a thread safe object can be quite tricky and can include some overhead, not many classes in the framework are really thread-safe.
For a not thread safe class, the developer has to take care that the same object cannot be used by two threads at the same time.
Regards,
mav
|
|
|
|
|
Hi
Mav...
Nice explanation..!
Thanks
M.Sendilkumar
TVS Infotech Ltd
Chennai
|
|
|
|
|
you're welcome.
The problem with threads is that it's very easy to forget that they're there...
Recently I've stumbled across a problem where a customer called and complained about an error message in on of my programs saying that an enumeration cannot be modified within a foreach loop.
I was completely stumped because I had taken explicit care that I'm not removing items from a hashtable I was working with in a foreach, but still this error occurred.
After a while it dawned on me: I had a timer that was checking the entries in the hashtable and this function worked flawless. But I also had a FileSystemWatcher set up that was adding entries to the hashtable. And when this occurred just when the timer callback was running this error occurred.
Luckily, putting a lock(_myHashtable) { ... } here and there solved the problem quickly.
mav
|
|
|
|
|
hi!!
i'm looking for a way to
Managing User Accounts and Gruops at Runtime using C# code...
is that possible??
thanks!
Girls: 0 succeeded, 47 failed, 1 skipped
|
|
|
|
|
HOW TO: Add a User to the Local System by Using Directory Services and Visual C# .NET
http://support.microsoft.com/default.aspx?scid=kb;en-us;306273
.NET Framework Class Library
System.DirectoryServices Namespace
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdirectoryservices.asp
|
|
|
|
|
Hi everybody, Am in great trouble.
I have a project MyApp.exe which is a big project. It has some 20-30 dll dependencies on it. The resource (including dialog boxes) is in a separate dll. This project had been developed in VC6 previously and hs now been ported to .NET. Its running fine.
The thing is, I want to make the dialog boxes appear with the Windows XP visual style. So, when an user selects Windows XP style from Control Panel->Appearance tab, the appearance of the dialogs should change too. It must not have the classic style appearance.
For this, I have followed the methods outlined in MSDN site. I am giving the links too.
1) http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwxp/html/xptheming.asp
2) http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/userex/cookbook.asp
Th process given above works fine for a simple dialog-based project.
But, where, even the resource is in a separate dll, there, it doesn't work.
PLEASE DO GIVE ME ANY FEEDBACK OR SUGGESTIONS ASAP.
|
|
|
|
|
HI All,
Just an eager frame of mind an question arises on my mind that how the .net runtime engine bind an assembly to the code executed and also wants to know about the static and dynamic binding of the assembly.
Thanks
Pankaj Gupta
Sr Software Engineer
|
|
|
|
|
Hi ,
.Net provides the Reflection class for loading the assembly at runtime.
this is the dynamic binding of assembly.
For static binding you can go for the Addreference , to add the assembly at compile time.
Regards,
Sukesh.g
|
|
|
|
|
Hi,
I need to build a Web service for a chat application with .NET Remoting. It means the remote objects must be hosted in IIS but IIS is stateless and the only remote object type we can use is SingleCall. However, the application must manage the state of all users who is chatting and I need to use the Singeton object.
I heard that we can use Application state, Session state to keep the state of application like the way ASP.NET does but I don't know how to implement it with .NET Remoting.
Next, it is a service which hasn't got the main() function to construct parameters before the application really starts. So where can I construct these parameters?
Therefore, please help me:
1. How to construct parameters before the application runs?
2. How to keep the state of application?
If you have some examples, could you show me?
Thanks advance.
abc
|
|
|
|
|
|
Hi
We are using Authorization and profile application blocks (Microsoft Design patterns).We are trying to access the Azman Provider we are not able to access the dll which is added in the references already in the client application.If you can provide us some code snippets that would be really very helpful.I am providing my client application here.
*******************Code*********************
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
//Error ,in accessing the reference that is added
using Microsoft.ApplicationBlocks.Security.Provider; //cannot access the provider.
using Microsoft.ApplicationBlocks.Security.Authorization;
using Microsoft.ApplicationBlocks.Security.Profile;
using Microsoft.ApplicationBlocks.Common.Crypto;
using System.Security.Principal;
using System.Configuration.Assemblies;
using System.Threading;
using Microsoft.Interop.Security.AzRoles;
namespace myClient
{
public class WebForm1 : System.Web.UI.Page
{
string userRole="Manager";
private void Page_Load(object sender, System.EventArgs e)
{
Microsoft.ApplicationBlocks.Security.ExtendedPrincipal principal = Microsoft.ApplicationBlocks.Security.ExtendedPrincipal.Create(Thread.CurrentPrincipal.Identity);
Thread.CurrentPrincipal =principal;
principal.AuditIdentifier ="MyAuditIdentifer";
principal.AuthorizationProvider="azmanProvider";
principal.AuthorizationParameters.Add(AzManProvider.ApplicationName,"myApplication");
if(Thread.CurrentPrincipal.IsInRole(userRole))
{
((ExtendedPrincipal)Thread.CurrentPrincipal).AuthorizationParameters.Add("tasks",new string[1] {"AddOrderTask"});
if ( ((ExtendedPrincipal)Thread.CurrentPrincipal).CheckAccess())
{
//quickStart.AddOrder();
}
else
{
Response.Write("Add Order Access Denied");
}
}
Hashtable parameters = new Hashtable(5);
parameters.Add("principal",Thread.CurrentPrincipal);
((ProfileCollection)((ExtendedPrincipal)
Thread.CurrentPrincipal).Profile).
Initialize((ExtendedPrincipal)Thread.CurrentPrincipal);
// Accessing the Profile Information from the ProfileCollection:
Response.Write("Profile Information from the Profile Collection thru the ExtendedPrincipal");
Response.Write("Profile Information: 'Preferred Investment Type' is "+(string)((ProfileCollection)
((ExtendedPrincipal)Thread.CurrentPrincipal).
Profile)["stockProfile"]["preferredInvestmentType"].Value );
Response.Write("Profile Information: 'Trades Frequently' is " +
Boolean.Parse(((string)((ProfileCollection)
((ExtendedPrincipal)Thread.
CurrentPrincipal).Profile)["stockProfile"]
["tradesFrequently"].Value)));
Response.Write("Profile Information: 'Most Traded Stocks' is " +
(string)((ProfileCollection)
((ExtendedPrincipal)Thread.CurrentPrincipal).
Profile)["stockProfile"]["stockTrades"]
["mostTradedStocks"].Value);
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}
With Many Thanks
kiran
|
|
|
|
|
This is probably one of the strangest things I think I've seen while working in .NET and I have yet to figure out even a workaround, much less why it might be occurring.
I've got a very strange bug happening which I was finally able to distill down to a problem with writing to ..\..\app.config after a file open dialog. It appears that if a standard file open dialog is closed with the "open" button then any future writes to app.config just magically disappear into the bit bucket (am I the only one still using that term?). No errors, no exceptions thrown. In fact, if you close the app.config stream and open it from scratch, the changes just written appear to be there but when the app finishes, they aren't there. This sounds like a buffering problem but I'm setting the stream to autoflush and flushing/closing it after the save. Also, if you have the file open in the IDE at the time, you can write to it and save it just fine. None of this happens when you hit the cancel key in the open file dialog even though I'm totally ignoring the return from the dialog in both cases. None of it happens with files other than ..\..\app.config (at least not with the sample file I tried in my temp directory).
I have no idea why the file open dialog and app.config would be tied together in such an inextricable manner. I don't know how I'd simulate such a strange situation WRT app.config even if I tried. The best I can think of is to overwrite app.config and change it's creation date back to what it was originally but this isn't happening because I can write to it from the IDE while this is happening and those writes aren't overwritten. This one definitey has me scratching my head.
To illustrate the bug I wrote a tiny app with a single button which calls the following function when the button is pressed. This pretty much illustrates everything I'm talking about (forgive the formatting - all my blank lines seem to drop out in the <pre> block - anybody know how to get them to show up?):
private void XMLBugSave()
{
const string strFile = @"..\..\app.config";
XmlTextReader xr = new XmlTextReader(strFile);
xdoc = new XmlDocument();
xdoc.Load(xr);
xr.Close();
Random rnd = new Random();
string strNodeName = "NODE_" + rnd.Next().ToString();
Console.WriteLine("Attempting to add Element " + strNodeName);
xdoc.DocumentElement.AppendChild(xdoc.CreateNode(XmlNodeType.Element, strNodeName, null));
OpenFileDialog ofd = new OpenFileDialog();
ofd.ShowDialog();
StreamWriter sw = new StreamWriter(strFile);
sw.AutoFlush = true;
xdoc.Save(sw);
sw.Flush();
sw.Close();
MessageBox.Show("Verify file...");
xr = new XmlTextReader(strFile);
xdoc = new XmlDocument();
xdoc.Load(xr);
xr.Close();
XmlNode xn = xdoc.SelectSingleNode(@"/configuration/" + strNodeName);
Console.WriteLine(xn == null ? "unverified" : "verified");
}
|
|
|
|
|
you'll kick yourself when you read this.
.NET Framework Class Library
OpenFileDialog.OpenFile Method
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwindowsformsopenfiledialogclasstopic.asp
|
|
|
|
|
Hi,
I have developed a .NET application. What is currently missing is a copy protection. My customers are mostly in other cities and in same sector. When I send a copy to a customer I want to be sure that it is not copied and used without my knowledge. What do you use to protect your applications?
|
|
|
|
|
Hi all,
I've created an ActiveX control using Visual C++ .NET.
When I add this control to a container created with Visual C++ .NET (or a Visual C++ 6.0) everything works and there is no apparently problem. But now, I'm trying to test this ActiveX with an application created with Visual Basic 6.0. The problem is that the ActiveX control does not appear in the list of registered components from the Visual Basic 6.0 (Menu -> Project -> Components, or Ctrl+T). So, I can't add my ActiveX to the Visual Basic 6.0 container.
When I try to make the same operation with a Visual Basic .NET container, I find the same situation, this is, the ActiveX control is not in the registered components list. But the ActiveX control is already registered.
I use the OleView application in order to ensure that the control is registered.
Due to my ActiveX control perfectly works with a Visual C++ .NET (and a Visual C++ 6.0) container, I suppose there is any bad chosen compiler option (by the time, everything is by default). Does anybody experimented the same situation testing his/her ActiveX in a Visual Basic container?
Thanks in advance.
|
|
|
|
|
I need to draw a chart (in 2D) and I'm programming in Visual C++ (.NET version 2003). I can´t use the controls in: http://www.codeproject.com/miscctrl/#Charting+Controls
because I'm not using MFC.
I've read that there is an ActiveX control called Microsoft chart Control but I don´t know how to use an ActiveX control in visual c++.
Please help me!!!
|
|
|
|
|
You can import the type library for Microsoft Graph (a COM component of Microsoft Office), and use the Type Library Importer (TLBIMP.EXE) to convert this to an assembly, which you can examine with the IL Disassembler. However, this is a major pain in the ass and it takes alot of time to learn your way through it all. There are help files for all the Microsoft Office components, located somwhere in that directory, but they are written for Visual Basic programmers. They do however describe the object hierarchy well enough to get you started.
It would be mush easier to actually draw the chart using GDI functions.
How complex is the chart? Do you have to create many of them?
|
|
|
|
|
It's a XY chart, I think that it's not very complicated. I have to create a lot of points and then draw lines from one point to another with DrawLine. Am I right? Is there a way to make it easier?
I have a variable number of points, and it can reach a high number so I won´t have enough pixels to draw the chart. In that case I don´t know what to do.
Thanks ursus zeta for replying
|
|
|
|
|
Hey, sorry for not getting back to you.
I'm used to using the GDI functions in Win32 applications, so I haven't done much design in .NET. But the Framework classes call the underlying Win32 functions, which, in this case are pretty simple and commonly used. The Graphics object is similar to the Device Context in the Win32 API. I believe you instantiate the Graphics object (with the new operator), and then, you can use Intellisense to help you through the process.
In Win32, you specify a point, and then to draw a line (after selecting a Pen into the Device Context) you call two functions, the first sets the beginning and the second draws the line to the end point (which you supply as a parameter). It's quite simple; and, I'm sure the .NET Framework methods are as easily used (but, I haven't played around with it, so, I have no example code).
You might read through the MSDN documentation, and explore the DrawLine method:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdrawinggraphicsmemberstopic.asp[^]
|
|
|
|
|
hi all ...
i'm developing a program that gets all the processes running on the computer and display them in a list view control and i'm using a timer that update the processes in the listview every 2 sec...the problem is that if there is a selected item in the list view and the list view updated .. the selection on the item just gone ...how can i track the selected item so that the next time the list view updated ....the same item is still selected...
thank you for your time
|
|
|
|
|
Hi, there isn't any simplier method, than store name of selected item in local variable, refresh listview and find item with same name as you have in local variable.
Something like this:
string name="";
if (view.SelectedItems.Length!=0)
name=view.SelectedItems[0].Text;
for(int i=0; i<view.Items.Length; i++)
{
if (view.Items[i].Text==name)
{ view.SelectedIndices[i]=true; break; }
}
|
|
|
|
|
hi all.. i'm developing a program that get the current processes that are running on the computer and if any process has i user interface getting the name of this GUI of the process...i'm checking if the process has MainWindowHandler...if so i'm getting the process MainWindowTitle....it is working fine but for processes such as Explorer.exe or Iexplorer.exe ... the MainWindowTitle doesn't return anything...i wanna return the urls that the ie launching ...or the folders that are opened now...how can i accomplish this??
thank for ur time
|
|
|
|
|
I have written a custom OLE DB Provider for a propritary Database (built on top of SQL Server provider). I want to move all my code to .NET from VC 6. Since the .NET Data Providers do not provide functionality outside of ADO.NET (Like in Excel or Crystal Reports) I cannot use the new data provider platform. Is there a way through COM interop that I can consume a datatable in COM so I can have a .NET dll that does 90% of the work with my original provider code consuming the output of the new dll. I have seen all the COM interop examples and they all use the basic types like string double etc. If anyone has any ideas please let me know.
|
|
|
|