|
|
You'll have to call %WINDIR%\Microsoft.NET\Framework\v1.1.4322\csc.exe to get the C# compiler for .NET 1.1.
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
|
Hi All,
I want to write some application in Doc/view architecture -
What i mean is that i want it to be like Doc/view in the MFC ( like explorer style )
Can i do it in C# ?
If i can - so how to do it ?
Thanks for the help.
|
|
|
|
|
You create a document, then map a view onto that document. Although, you may be better off considering the Model View Controller pattern, as this allows you to connect multiple views to one model (document). Here's a pseudo .NET 3.5 version.
public abstract class ModelBase
{
public ModelBase()
{
Title = string.Empty;
FileLocation = string.Empty;
}
public string Title{ get ; set; }
public string FileLocation { get ; set; }
public abstract void FileSave();
}
public class MyDocument : ModelBase
{
public MyDocument() : base() {}
public override void FileSave()
{
}
}
public abstract class ViewBase<T> where T : ModelBase, new()
{
public ViewBase(T model)
{
Model = model;
}
protected T Model { get ; set ; }
public abstract void Refresh() {}
}
public class MyView : ViewBase<MyDocument>
{
public MyView (MyDocument doc) : base (doc)
{
}
public override void Refresh()
{
}
}
public class ControllerBase<T, U>
where T : ModelBase
where U : ViewBase
{
private T _model;
private List<U> _views = new List<U>();
public ControllerBase(T model)
{
_model = model;
}
public void AttachView(U view)
{
_views.Add(view);
}
public void RefreshAll()
{
foreach (ViewBase view in _views)
{
view.Refresh();
}
}
} I've just typed this into IE, so I apologise if the syntax isn't 100% correct but this should get you started.
|
|
|
|
|
Hi,
I develop an application by visual studio 2005, programming language C#, and doesn't used any other style tools.
After used my application, my friend give me his opinion that I shouldn't use office 2003 menu because it doesn't suite with GUI. he said I should use native vista menu. I think it's good idea so I want to change style menu, but In visual studio 2005, (menu option) Render Mode have 3 options: System, Programming, ManagerRenderMode.
I found out that Microsoft support a class VisualStyleElement but I don't know how to used it!
I wish some one can show me how to use VisualStyleElement class. I took a look at some sample in MSDN website but I didn't clearly understand.
Thanks
|
|
|
|
|
KienNT78 wrote: VisualStyleElement but I don't know how to used it
Google it.
"I guess it's what separates the professionals from the drag and drop, girly wirly, namby pamby, wishy washy, can't code for crap types." - Pete O'Hanlon
|
|
|
|
|
Google didn't help...All results are unuseful...
|
|
|
|
|
I have very large application its multi threaded as well now is it possible to know which methods was invoked like stack trace without having a breakpoint. The application has no error but i need to know which method of which class got executed.
|
|
|
|
|
|
I have a WS that has a number of methods, and two in particular must share a file. My question is, will the finally block in the following code run while the lock is acquired, or will it release the lock, then run the finally block?
public byte[] GetFile(string fileName) {
FileStream fs = null;
try {
lock (s_Lock) {
fs = new FileStream(..., FileShare.None, ...);
byte[] result = new byte[fs.Length];
fs.Read(result, 0, fs.Length);
return result;
}
} finally {
if (fs != null)
fs.Close();
}
}
public bool DeleteFile(string fileName) {
lock (s_Lock) {
File.Delete(fileName);
}
} The thing I am worried about is that I am opening the file with no sharing allowed, so I want other calls for the same file to wait for the file to become accessible. So if GetFile is currently being run (has the lock) and DeleteFile is waiting for the lock (both with the same file name argument), then is it possible that prior to the call to fs.Close() that the DeleteFile method attempts to remove the file (which would result in an exception since the file is already open)? Thanks,
Sounds like somebody's got a case of the Mondays
-Jeff
|
|
|
|
|
Yes, you do have a race condition. The lock block's scope is within the try block, so it is essentially
try
{
try
{
Monitor.Lock(s_Lock);
...
}
finally
{
Monitor.Unlock(s_Lock);
}
}
finally
{
if (fs != null)
fs.Close();
}
So yeah, DeleteFile could potentially run in parallel with the finally block.
Moving the lock block outside try/finally solves the problem. And if all you're doing is closing the FileStream in the finally block, you might want to use a using statement instead. Like
lock(s_Lock)
{
using(FileStream fs = new FileStream(...)
{
fs.Read(...);
}
}
Hope that helps.
|
|
|
|
|
Thanks for the help!
Sounds like somebody's got a case of the Mondays
-Jeff
|
|
|
|
|
With Martin Luther King Day approaching, we should all look to eliminate race conditions. 
|
|
|
|
|
PIEBALDconsult wrote: With Martin Luther King Day approaching, we should all look to eliminate race conditions.
I have a dream that one day this operating system will rise up and live out the true meaning of its creed "We hold these truths to be self-evident: that all threads are created equal and shall not interfere with each other."
|
|
|
|
|
Hello Everyone!!
I'm trying to add a delegate to a Dictionary<string, object>, hence of running it through IronPython (script file).
I have managed this (look at the code) but now I want to do this dynamic. In other words I don't want
to declare a delegate for every method in my class (ExCode. AddItem in Actor).
The problem is the method CreateDelegate and the first argument. I can't bind a dynamic type representing the type of delegate to create. I have not found a solution for this on CodeProject but where is greatly on the subject.
Dynamic Code Generation vs Reflection By Herbrandson
Fast late-bound invocation through DynamicMethod delegates By Alessandro Febretti
A General Fast Method Invoker By Luyan
This is the code:
<br />
using System.Reflection;<br />
using IronPython.Hosting;<br />
<br />
public class Actor<br />
{<br />
private string objectID;<br />
private int count;<br />
<br />
public void AddItem(string objectID, int count)<br />
{<br />
Console.WriteLine(string.Format("{0}, {1}", objectID, count));<br />
this.objectID = objectID;<br />
this.count = count;<br />
}<br />
}<br />
<br />
public class ActorScript<br />
{<br />
protected delegate void AddItem(string objectID, int count);<br />
protected Dictionary<string, object> locals = new Dictionary<string,object>();<br />
protected Actor actor;<br />
<br />
ActorScript(Actor actor)<br />
{<br />
this.actor = actor;<br />
Initiate();<br />
}<br />
<br />
private void Initiate()<br />
{<br />
MethodInfo methodInfo = typeof(Actor).GetMethod("AddItem", BindingFlags.Public | BindingFlags.Instance);<br />
this.locals.Add("AddItem", Delegate.CreateDelegate(typeof(AddItem), this.actor, methodInfo));<br />
<br />
}<br />
<br />
public void Run(string fileName)<br />
{<br />
PythonEngine engine = new PythonEngine();<br />
engine.ExecuteFile(fileName, this.engine.DefaultModule, this.locals);<br />
}<br />
}<br />
<br />
This is the script file:<br />
<br />
ItemScript.py<br />
AddItem("Sword", 2)<br />
Any help would be appreciated.
Best Regards,
Gywox
modified on Tuesday, January 15, 2008 5:13:06 AM
|
|
|
|
|
Its probably easier to just wrap a delegate like so:
this.locals.Add("AddItem", delegate(string object, int count) { this.AddItem(object, count); })
It might be even easier to use Boo (which has a very python like syntax) as your scripting language - as you can just expose your whole Actor instance to the Boo interpreter (or compile it).
You should probably make sure that IronPython can't reference an object instance as well before you go down this route.
|
|
|
|
|
Hi Mark
One can expose instances to IronPython, but in this case I don't want to.
I have the script function in a database, and I wish to connect the class methods and
the script commands by this mean.
|
|
|
|
|
Messing around with delegates in this way just seems a little messy.
Whats your real objective here? Stopping your script files from affecting the object model too much? Just expose stuff like IScriptActor which has only the functions you want to expose.
|
|
|
|
|
Hi,
Has anybody done a comparison between these 3 component suites? I need to pick one to integrate in my Windows-based app (the app has UI galore). After a quick glance, C1 doesn't seem very structured (has a lot of do-it-all components - the FlexGrid can also do Trees), whereas Infragistics and Syncfusion seem better layed out (I really like Syncfusion's docking manager).
Most likely I'll have to write small apps with each suite to figure out if they have what I need (for example listView drag'n drop is a big one, because now I'm using XCeed and their drag'n drop is a joke), but I thought I'd ask others what's their take on this (speed, feature set, memory footprint, stuff like that). If you haven't compared them, but are currently using one of them, please tell me what you think of it.
thanx
|
|
|
|
|
I don't have any experience with the other two, but I have used Infragistics for both web and windows apps. I would look for something else. Infragisitics has poor documentation and customer support, it seemed to me as though their controls were carelessly rushed to market with the hope that they could be fixed with service packs.
only two letters away from being an asset
|
|
|
|
|
We are using Syncfusion at work for a project under development, and I cannot recommend it to anyone. We've had to put up with buggy controls, not recognizing valid licenses, and horrible support.
I'm sure there are people out there with nothing but good to say about Syncfusion. My co-workers and aren't among them.
I cannot really give you any advice on the Component1 or Infragistics, but I have used DevExpress' controls, and they work quite nicely. I have noticed no bugs whatsoever, and their support is responsive and helpful!
|
|
|
|
|
Hmm.. DevExpress wasn't on my list, but I'll sure take a look, now that you brought it up!
Could you tell me what controls did you find buggy in Syncfusion?
thanx
|
|
|
|
|
i worked with both infragistics and syncfusion controls (use some controls)
and it is true as said by mark infragistics lacks good documentation
u have to spent a time on it's forumn to do something...
syncfusion's grid is more fast than the infragistic's grid
some of infragistic's control are hard to implement only due to lack of documentation
|
|
|
|
|
I started to use SyncFunsion, dont know about bug, but one thing I know... infragitics it is some time real hard to work with them as lack of documentation. this have been a problem for many years. Oscar Rangel
|
|
|
|