|
You could set all FileInfo references to null. The GC will clean them up when it wants to, or you could force it with GC.Collect (although this isn't recommend).
A warning / piece of advice: FileInfo doesn't actually open the file, though it has methods that will create certain types of streams for you. What is most likely the problem is that you're not closing the streams elsewhere. Below is a piece of code that is recommend and best to use when possible:
Stream s = null;
try
{
s = new FileStream(...);
}
catch (Exception e)
{
Trace.WriteLine(e.Message);
}
finally
{
if (s != null) s.Close(); (
} The finally block gets called no matter if the stream operations succeed or fail. Closing the stream frees the file system handle (FILE) to the file. Not closing the stream will most commonly lead to the problems you are getting.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Is it possible to set the toolbar component buttons to have text only buttons? If there is, what setting needs to be modified? Thanks
|
|
|
|
|
Not unless you override or make your own toolbar. One an image is set for one ToolBarButton , space is allocated for the rest. The ToolBar in the BCL does kind of stink, but there are plenty of alternatives available, including many here on CP and lots of commercial versions, too.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
hi i am asking for the way i can handle a voice event for example if i say
"start" an event will be invoke to open a program and if i say "save"the current file will be saved if you have an answer to this or any referense please send a mail to eafares265@hotmail.com thank you from lebanon to iran .
|
|
|
|
|
I guess in general you should look at the Microsoft Speech Application SDK on MSDN. It does speech both ways (recognition and text to speech). It's currently in Beta 3 I believe.
I, for one, do not think the problem was that the band was down. I think that the problem may have been that there was a Stonehenge monument on the stage that was in danger of being crushed by a dwarf.
-David St. Hubbins
|
|
|
|
|
please if you get any important referense to the voice event please let me know about it thank you for your time.
|
|
|
|
|
Hey gang,
Ok, I'm stumped on this one... I am using the using statement to wrap a SqlDataAdapter that I am using to fill a DataTable. Now, what I need to know is, just how much block-scope applies to objects created in the using scope.
For example:
<br />
static DataTable getTable()<br />
{<br />
using (SqlDataAdapter sda = new SqlDataAdapter("StoredProcedure", new SqlConnection("ConnectionString")))<br />
{<br />
DataTable dt = new DataTable("table");<br />
sda.Fill(dt);<br />
return dt;<br />
}<br />
}<br />
I know this would return a table with zero rows becuase it is created and destroyed within the scope of the using statement. But...
<br />
static DataTable getTable()<br />
{<br />
DataTable dt = new DataTable("table");<br />
using (SqlDataAdapter sda = new SqlDataAdapter("StoredProcedure", new SqlConnection("ConnectionString")))<br />
{<br />
sda.Fill(dt);<br />
}<br />
return dt;<br />
}<br />
Now, when I call this, I also get back zero rows in my table, yet when I run the query in SQL, it comes back fine. Anyone have any ideas or experience with the using statement?
TIA,
Bill P.
Oakland, CA
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCM/MU/B dpu s--:-- a32 C++++$ ULH+++ P+++ L++ E+ W+++$ N++ o K? w++++$ O-- M V-- PS+ PE+ Y++ PGP++ t++@ 5++@ X++ R+@ tv b++ DI++ D+++>++++ G++ e++ h---- r+++ y++++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
First, in either example, the DataTable is not disposed. Only the SqlDataAdapter is being disposed.
Second, your problem in both cases is that you're passing a stored proc name for the selectCommand parameter - read the documentation: this won't work. It must be a SQL command and only a SQL command. Instead, try this:
public static DataTable GetTable()
{
SqlCommand cmd = myConnection.CreateCommand();
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "StoredProcedure";
DataTable dt = new DataTable("Table");
SqlDataAdapter sda = new SqlDataAdapter(cmd);
using (sda)
{
sda.Fill(dt);
return dt;
}
} Also, if you're using a strongly-typed DataSet or DataTable , you'll also need to set up the SqlDataAdapter.TableMappings property.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Hey Heath,
Thanks for the quick reply... but...
According to the docs:
selectCommandText
A String that is a Transact-SQL SELECT statement or stored procedure to be used by the SelectCommand property of the SqlDataAdapter.
I forgot to put in the fact that I use sda.SelectCommand.CommandType = CommandType.StoredProcedure.
Anyhow... I've tried it a number of different ways, all with the same problem.. the DataTable never has rows in it. I understand what you are saying, but, if the data adapter gets disposed *after* the fill, why would the data table still return no rows?
I did this and had the same results.
<br />
public static DataTable getTable()<br />
{<br />
DataTable dt = new DataTable("table");<br />
using (Config config = new Config())
{<br />
using (SqlConnection conn = new SqlConnection(config.SqlConnectionString))<br />
{<br />
using (SqlDataAdapter sda = new SqlDataAdatper("Select * from table", conn))<br />
{<br />
sda.Fill(dt);<br />
}<br />
}<br />
}<br />
return dt;<br />
}<br />
return dt;<br />
Now, from what I have read about the using statement, this pretty much translates to:
<br />
public static DataTable getTable()<br />
{<br />
DataTable dt = new DataTable("table");<br />
Config config = new Config();<br />
try {<br />
SqlConnection conn = new SqlConnection(config.SqlConnectionString);<br />
try {<br />
SqlDataAdapter sda = new SqlDataAdapter(SqlDataAdatper("Select * from table", conn));<br />
try {<br />
sda.Fill(dt);<br />
}<br />
finally {<br />
if (sda!= null) ((IDisposable)sda).Dispose();<br />
}<br />
}<br />
finally {<br />
if (conn!= null) ((IDisposable)conn).Dispose();<br />
}<br />
}<br />
finally {<br />
if (config != null) ((IDisposable)config).Dispose();<br />
}<br />
return dt;<br />
}<br />
Believe it or not, when I run that code above, as is, it works fine. My table is populated and everyone is happy. Sorry to carry on, I am just trying to figure out the scope usage that MS wrote into the using statement.<br />
<br />
Any ideas? <br />
<br />
TIA,<br />
Bill P.<br />
Oakland, CA<br />
<hr size="2" noshade="" style="color: rgba(70, 130, 180, 1)">-----BEGIN GEEK CODE BLOCK-----<br />
Version: 3.21<br />
GCM/MU/B dpu s--:-- a32 C++++$ ULH+++ P+++ L++ E+ W+++$ N++ o K? w++++$ O-- M V-- PS+ PE+ Y++ PGP++ t++@ 5++@ X++ R+@ tv b++ DI++ D+++>++++ G++ e++ h---- r+++ y++++<br />
-----END GEEK CODE BLOCK-----<br />
<hr size="2" noshade="" style="color: rgba(70, 130, 180, 1)">
|
|
|
|
|
First of all, you don't need to worry about disposing managed objects all the time. The garbage collector will take care of that eventually. Disposing it just cleans it up immediately.
Second, the using statement merely causes the Dispose method to be called on objects that implement IDisposable . The DataTable is not tied to a SqlDataAdapter (i.e., not a field or anything else that gets disposed). Because you're giving the DataTable a name, the result have to match that name to be filled. Use a TableMapping mapping or don't give the DataTable and name and see what you get.
And yes, had you mentioned that you were setting the CommandType , I wouldn't have mentioned that. The default, however, is CommandText so it was worth mentioning from my perspective with the knowledge you provided.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Got it.. thanks for the assist. Unfortunatly, I have to worry about early disposal of my objects because I am running this on a shared server in the company and I need to really, really, REALLY manage my memory usage (***sigh grumble***)...
Thanks Heath...
Bill P.
Oakland, CA
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCM/MU/B dpu s--:-- a32 C++++$ ULH+++ P+++ L++ E+ W+++$ N++ o K? w++++$ O-- M V-- PS+ PE+ Y++ PGP++ t++@ 5++@ X++ R+@ tv b++ DI++ D+++>++++ G++ e++ h---- r+++ y++++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
i'm using the dotnetmagic.com docking component.
i want to develop the content of each dock in a library of its own. ( not using the dotnetmagic component ) the idea is to be able to re-use the same objects if i end up changing things to the application later.
for example, i have a search ( in a group box ) and a datagrid. i want to be able to call them from their own class.
should i attach the search and datagrid each to their own panels in their own library?
i know i'm not doing a very good job explaining this .. espeically if you haven't used the dotnetmagic component.
any advice would be appreciated.
|
|
|
|
|
I guess I don't see what the problem is. .NET Magic doesn't care about where the content comes from. They are simply forms and can be in any assembly. When creating your docking manager and the content, instantiate the control from whatever library (either through Reflection or using assembly dependencies) and add it to the content. If you want to be able to refer to these controls directly instead of enumerating the content in a docking manager, then as you instantiate these various controls in any number of libraries, keep a collection (either local to the form that contains the docking manager, or some static collection that is globally accessible) or hashtable (same advice as for collections). We do something very similar in our application with no problem.
It's no different than creating a basic form with a default Button or DataGrid (for example). They are defined in the System.Windows.Forms assembly and your form isn't. The same is true for almost any language runtime in existence, for that matter.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Hello All.
I have this error in my application and I have no idea of what I'm doing wrong:
'ALINK: error AL1057: Executables cannot be localized, Culture should always be empty'
MSDN says about this 'An assembly is being created with /target:exe but /culture was specified. Assemblies in the .exe cannot have information in the Culture field'.
I can understand what this means. Anyone can explain to me ??
Thanks.
|
|
|
|
|
It means don't use the /culture switch! The main exes and dlls are always compiled into language neutral assemblies. You can control which language is neutral by using the System.Globalization.NeutralResourcesLanguageAttribute , an assembly-level attribute that you would typically put in your AssemblyInfo.cs file (although it can go anywhere, so long as it is appended with the assembly: prefix, like [assembly:NeutralResourcesLanguage("en-US")] .
The /culture switch is used for satellite assemblies - assemblies that contain localized resources (in source form, these are ResX files). They contain no code. You can also create localized assemblies by using the AssemblyCultureAttribute , but these projects may not contain any code - only .ResX files (which are compiled to .resource files).
You can find out more in MSDN about satellite assemblies at http://msdn.microsoft.com/library/en-us/cpguide/html/cpconsatelliteassembliesside-by-sideexecution.asp[^] and localizing resources at http://msdn.microsoft.com/library/en-us/cpguide/html/cpcondesigningglobalapplications.asp[^].
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Thanks for your response, but I'm still lost.
I don't know how to turn off the /culture switch.
The only thing I know about culture is that in the project I have a form in spanish and I want to translate it into English, so I put the Localizable property to true and then I selected into the languaje property English. Then I translated the form into English and after that I get the error.
Is this the cause of the error ? How can I turn off the /Culture swicth ?
Thanks in advance.
Bye.
|
|
|
|
|
Did you read the links I gave you? They discuss localization in great length. First, if you are authoring the original forms in Spanish and it is in that locale that all your code is contained, then use the NeutralResourcesLanguageAttribute and specify the appropriate culture. Second, try going back to the "default" culture (actually the neutral culture) in your form designer and compile again. VS.NET might thing that you're trying to compile the English satellite assembly as the primary assembly.
Second, show hidden files in your project. Look at the ResX files. If you use VS.NET's designers, these will be hidden under forms. If your form source file is named MyForm.cs, then you should have a MyForm.resx (the neutral language) and MyForm.en.resx or MyForm.en-US.resx.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
I don't understand the "readOnly" parameter to PerformanceCounter constructor:
public PerformanceCounter(
string categoryName,
string counterName,
bool readOnly //QUESTION: If it's only readOnly, what's the use of the counter if you cannot update/increment it??
);
Thanks!
|
|
|
|
|
CillyMe wrote:
what's the use of the counter if you cannot update/increment it??
If u just wanna read it....
leppie::AllocCPArticle("Zee blog"); Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.
|
|
|
|
|
for(int i=0; i< ; i++)
{
leppie.Delete( );
}
|
|
|
|
|
U certainly cant modify counters like CPU usage etc....
leppie::AllocCPArticle("Zee blog"); Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.
|
|
|
|
|
I want to copy data from one excel workbook to another. I have a range named 'MyRange' in workbook 1 on sheet 1. I want to copy this range to sheet 1 in workbook 2. More: I want to paste values and formats instead of formulas.
The VBA code looks like this:
**********
Application.Goto Reference:="MyRange"
Selection.Copy
Sheets("Sheet2").Select
Selection.PasteSpecial Paste:=xlPasteValues, .....
..
Application.CutCopyMode = False
**********
Any hints??
PEK
|
|
|
|
|
Hi All,
I am new to component development.
I want to create custom control to show selected objects in form of polygonal shape.
The objects are placed in separate panel on the same form.
Those should be dragged and arranged in required shape.
This is to show user how many euipments are present in factory.
On clicking any of this cirular control details of particular equipement are displayed.
Intially there should be four circular images placed in form of rhombus, and then when one more such object is dragged to the control display area, all 5 objects should be rearranged in form of pentagon.When one more object added they should look like hexagon.
Can you please suggest me any links where I can get infromation about creating such custom control or what steps should be taken to implement above functionality?
Thanks in advance.
Regards
Shailaja
|
|
|
|
|
You should check out GoDiagram. What you're talking about can be done but there's a lot of calculations and drawing. Plus, if you want to use shaped pictures on a canvas to represent different machines, you'll need to create an object model. GoDiagram has all that and at a good price. Just get GoDiagram with the layout model and it can do all this for you and is extensible.
Otherwise, you're going to have to do the math yourself. You can get the controls in a container (like the UserControl , or it if contains other controls you don't want positioned, you can use another Panel or something or filter the Controls collection as you enumerate the controls). For how many there are, you need to calculate the position. There's lots of different equations to help you, but you still have to code them. You also have to decide what the anchor point for each control is (i.e., one of the corners, the center, or other anchor point) and position the controls so that they don't overlap - resizing your virtual polygonal grid. That's not too bad since you can get the Size of each control and calculate the anchor point (probably good to have a separate method to do so and abstract that functionality so you don't have to include it all in one method).
When doing this, you have to take into account the relative position of each control. When calculating the anchor point, for instance, the Size of the control is for the control itself. The Location (a Point ) is relative to its container. Because these two things are used for the Bounds property, you'll need to take that into account.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Let's say you have:
Location: WebService: COM+ component:
___________________________________________
ServerRoot WebServiceRoot COMPlusRoot
ServerA WebServiceA COMPlusA
ServerB WebServiceB COMPlusB
In WebSericeRoot (residing on ServerRoot):
[Transaction(TransactionOption.Required)]
[AutoComplete(true)]
[WebMethod(...)]
public void PlaceOrder(..)
{
WebServiceA service_a = new WebServiceA();
service_a.UpdateInventory(); //This will call COMPlusA residing on ServerA --> This will launch a new transaction!
WebServiceB service_b = new WebServiceB();
service_b.UpdateShipping(); //This will call COMPlusB residing on ServerB --> This too, will not participate in PlaceOrder's transaction and launches its own.
}
Even if UpdateInventory() and UpdateShipping() requires transaction, two new transaction will be started. In other words, COMPlusA and COMPlusB will start their own transaction because COMPlusA/COMPlusB and COMPlusRoot objects all resides in different server.
What are my options to implement distributed transaction across machine boundary. Do I need to roll my own transaction? Thanks.
|
|
|
|