|
Hi!
Thank you for you reply! I realize that what I was trying to do was not as easy or smart as I thought..
What puzzles me is that it works well if I use a delegate with only a string as a argument. Why does that work?? I cannot have a delegate with two strings as arguments, but one work. I tried to implement the ISerializable interface. That did not work either.
I can buy the thought of the events not working if the server cannot find the client, that is reasonable. But why does it work if the argument is a string??
Best Regards
Mikke
|
|
|
|
|
Consider what is happening when you "sign up" for the event. You need to send a message to the server object to add ClientObject.ClientFunction to the delegate list. Assuming ClientObject is a MarshalByRefObject , it can marshal "itself" across. It can also marshal strings across. So technically it will succeed in making the functional call across the .Net Remoting. The problem is that it is meaningless to the server app domain because of all of the stuff I meantioned before. All of the object references only work in the client domain and will "blow up" if used in server domain.
Oh yeah, I did mention a way to work around the limitation in .Net Remoting but it might not be clear without an example:
ObjectA CallRemoteB()
{
b.Call();
if(this.ValueChanged != null)
this.ValueChanged();
}
The event/delegate is now only in the client app domain so everything works.
|
|
|
|
|
I'm using VS2005 RC1.
I have a project file which has several applications inside it. These applications all need to use some of the same classes. I'd like to define these classes in one file that is shared among the applications, but defined in a separate namespace. The windows applications all are in separate namespaces as well.
I tried adding a new class to the project in a new solution folder in a new class file. I added a new new space to the file containing the classes, but to no avail. I could not figure out how to access the classes from the other namespaces in the applications.
Can someone explain the correct way to do this? Thanks.
|
|
|
|
|
set references
and all classes u want to share must be public
eg.
public class foo{}
Please pardon my weak English!
|
|
|
|
|
To access classes in say a class library you need all of the classes you are accessing to be public, and you need to add a reference to the library. If the library isn't in the solution you can add reference by dll, but if the library project is within the current working solution you can add reference by project. There is a references folder in the solution explorer which is were you can access the references dialog.
Matt Newman
Even the very best tools in the hands of an idiot will produce something of little or no value. - Chris Meech on Idiots
|
|
|
|
|
I'm a bit confused still. Here's the thing.
In my project file there are two applications and a "Solution Items" folder that contains a .cs file with several helper classes and enums defined inside.
These classes are declared public, and make use of the enum's defined in this file as well.
What I can't figure out how to do, is access the classes from the other applications defined within the project file.
I tried like you said, adding a reference to the file individually from the "Add Reference" selection that appears when you rightclick an application within the project.
However, my classes nor my solution file that contains the classes appear in any of the tabs available from within the references tab.
Can you reiterate on what you said, to clear this up for me a little bit?
Thank you.
|
|
|
|
|
Create a new project item of type class library (give it a name like "myapp_shared" or whatever makes sense to you). move the cs files that are in your 'solution items' file there. build that project (it should create a dll). in the other projects refence the new project, and add a "using" for the namespace that contains the shared classes. This will require you to distribute the dll with both applications, but is the easiest and most maintainable way to share functionallity...
Absolute faith corrupts as absolutely as absolute power
Eric Hoffer
All that is necessary for the triumph of evil is that good men do nothing.
Edmund Burke
|
|
|
|
|
I don't understand why you want the same classes to appear in different namespaces. I would think you would shared classes to appear in a common namespace that was used by all the applications. This might require putting the shared classes in their own dll, but that would seem more maintainable in the long run.
Absolute faith corrupts as absolutely as absolute power
Eric Hoffer
All that is necessary for the triumph of evil is that good men do nothing.
Edmund Burke
|
|
|
|
|
Granted, I'm new to C#. But I don't want the helper classes defined in the solution file to be put in separate namespaces, I want them to be in their own namespace that is accessable from the different applications, to avoid confusion.
I'm going to try the DLL solution you mentioned and see if I can get that to work.
Just to reiterate on my goal:
The applications in the project are contained within separate namespaces because MOST of the data in each is not used in the other. However, some of the basic data is derived from the same classes. Those classes I've put in a separate file in their own namespace. Just to show the structure:
The first two applications are like so:
Application 1:
namespace client
{
... // requires processing of class helper1 and helper 2
}
Application 2:
namespace server
{
... // requires processing of class helper1 and helper 2
}
SolutionFile.cs
namespace helper
{
enum type1 { ... }
enum type2 { ... }
class helper1 { ... } // USES ENUM TYPES
class helper2 { ... } // USES ENUM TYPES
}
I hope that clears up my problem a bit.
|
|
|
|
|
I want make my C# application to get all procedures' defination from IQ database using SQL "select * from sys.sysprocedure where proc_id>200",but when executing this sql,the exception "Capacity must be larger than 0" occused.
m_command = m_connection.CreateCommand();
m_command.CommandType = System.Data.CommandType.Text;
m_command.CommandText = m_strSql;
m_reader = m_command.ExecuteReader();
public Object this[String key]
{
get { return m_reader[key]; }
}
public String GetString(String key)
{
Object value = this[key];
if (Convert.DBNull.Equals(value))
{
return null;
}
else
{
return Convert.ToString(value);
}
}
How to get the long text which length more than 8K?plz help me!
Please pardon my weak English!
|
|
|
|
|
Hello
How I can show TV with Managed DirectX 9 ?
Can you showme a sample ? please
Thanks
|
|
|
|
|
Hy guys.
I'm Alessio, I don't speak english very well, so excuse me in advance.
I'm writing because I'm getting an error when I use the Graphics.DrawImage method with ImageAttributes parameter.
I've created a Form class to customize the TitleBar.
This "base" form is borderless and in the Constructor I store a small "gif" (30-40 Kb) in a bitmap object with the TitleBar I want to put in the form.
In the paint event I call a procedure passing the PaintEventArgs Graphic object and then I call the DrawImage using the bitmap object.
When the form has got the focus, I call "simple" DrawImage method, but when this form loss the focus, I use the ImageAttributes.SetGamma to brighten up the TitleBar (I pass "0.55f" to SetGamma) and then I call DrawImage passing the ImageAttributes object.
When I run my project, it's ok, but if I create a form that inherits from the "base form", and run the project, I've got an "out of memory" error when this form loss the focus.
Can you help me to understand ?
Thanx anyway
Alessio
|
|
|
|
|
Just a correction.
In that project I can load image from an extern file or from an embedded image I had added in project resource file.
In both cases I tried gif, png & jpg.
When forms are using external images, it's all right but when they use embedded image the "out of memory" error comes up.
I load this image in a Stream object through "Assembly.GetManifestResourceStream" method and then I create my bitmap object by "new Bitmap(MyStreamObj);".
If I use an Image object instead of the Bitmap object, all works fine, but I need Bitmap object because in the case of jpg images I need to call MakeTransparent method.
So, please, help me.
|
|
|
|
|
hi
i have a button in my page and add this attribute to button
<<button.attribute.add("onclick","<u>javascript:return confirm('Message');")>>
and also i have a textbox in my page that a requirefiledvalidator check that control not be empty.
if i click button, confirm window occur for me and if i press <<ok>> the code of this event execute while textbox is empty and validator not check the textbox. when event onclick of button finished validator check the textbox.
please help me.
thanks a lot.
|
|
|
|
|
hi there,
did u set isvalid = true in ur aspx page?
anyway, this is for C#, not ASP.NET forum ;(
<< >>
|
|
|
|
|
Hi all,
I want to place multiple bitmaps into one picturebox at the
same time placing them into different areas of the picture box.
Is it possible?
or any other way to do it.
Thanx
Rashid
|
|
|
|
|
Use the Graphics.DrawImage() either by creating a CreateGraphics() or Paint Event Handler e.Graphics
|
|
|
|
|
I have a class library written in C#. I have use it using "Add Reference" in a VB.NET windows application. Is there any way to lock the class library(dll) in such a way that no further "Add Reference" is possible ? Basically I want to prevent the reusability of the dll file for any other application except the VB.NET application, I told above. Is there any way to do such things?
Thank you in advance.
Anindya Chatterjee
|
|
|
|
|
hi there,
Why do u want to do that???
.NET is designed as OOP to save time/cost to develop software by reusablity mechanism!!!!. Just my thought
<< >>
|
|
|
|
|
If your code is ran trhough an obfuscator you could add require hte constructors of all the classes in the dll to fail if not provided a correct magic number. This would require modification of the calling app however.
|
|
|
|
|
I want to instance StrongNameMembershipCondition class.
[C#]
public StrongNameMembershipCondition(
StrongNamePublicKeyBlob blob,
string name,
Version version
);
the type of parameter blob is StrongNamePublicKeyBlob. I do not know how to get the parameter.
Can you help me? give some code.Thanks!
|
|
|
|
|
|
Hi,
I have the following regular expression:
// Validate news ID
Regex objPattern = new Regex(@"\d$");
string strID = Request.QueryString["id"].Trim();
bool boolSucess = objPattern.Match(strID).Success;
Basically this must test if id is just numeric. If I were to type in 44, then it is fine, if I type in 44E, then it is wrong. But when I type in 44.0 then the success is true. Why is this? I only want digits from 0-9 displayed, nothing else, no commas or decimal points.
Please could someone help. Let me know if my regular expression is incorrect.
Regards,
ma se
|
|
|
|
|
@"^\d+$"
xacc-ide 0.0.99-preview7 now with C#, C, C++, IL, XML, Nemerle, IronPython, Perl, Caml, SML, Ruby, Flex, Yacc, Java, Javascript, Lua, Prolog and Boo highlighting support!
|
|
|
|
|
Can anyone tell me how to create and delete a scheduled task in Windows. This can be accomplished using the AT command in DOS but I am unable to delete the scheduled task.
|
|
|
|