Explain Singleton Architecture Of Remoting?
Jun 6, 2011Explain Singleton architecture of Remoting.
View 1 RepliesExplain Singleton architecture of Remoting.
View 1 RepliesI have an Addin for MS Excel which needs a singleton to share data amongst modules.Depending on the version of Excel (2003, 2007, 2010), and how Excel was started, it calls my addin from different, unpredictable AppDomains, which prevents the classic singleton approach.Creating a custom AppDomainManager won't work because Excel has already created the AppDomains before the addin is called.
Linking to mscoree to enumerate domains breaks the addin registration process (and I really don't want that anyway); there doesn't seem to be any other way of enumerating, so that isn't an option either.The only solution that I've found is to use remoting. Here's my test rig:
Imports System.Runtime.Remoting
Imports System.Runtime.Remoting.Channels
' Remeber to add reference to System.Runtime.Remoting DLL[code].....
Once everything is running, access to the singleton takes ~100µS, which is perfect. I can live with the ~400mS the first time each AppDomain is initialised. The problem is at startup, where the remoting invocation takes ~2.5 seconds.
I have a question regarding the design of the Date object in the .Net framework, more specifically the Now property.I know that Now is a property that is a Date type. (This makes sense since I see the methods .AddHours(), AddYears(), etc) If Now being a class(or struct) how does it return a value directly.For example: How would I create a class or struct in C#/VB.net that would allow me to do the same without calling a property of Now?[code]To me it seems like you would have to call a another property off of TodaysWeather. But with the Datetime.Now example you don't.[code]
View 5 RepliesI'm not new to coding but fairly new to Visual Basic.Can someone tell me the difference between using the System.IO.Directory.Whatever and the Me.Computer.FileSystem.Whatever functions when it comes to file and folder manipulations?
View 1 Repliesi`m trying to understand the following code for video capturing but some things are very strange for me explain briefly the below code. If you can give any articles. Basically i`m trying to create my own video capturing program and i want to understand this one before starting my own.[code...]
View 4 RepliesSometimes there is a need to initialize the singleton class with some helper values. But we can't "publish" a constructor for it. What is the workaround for this?overloading the GetInstance or setting a color is not my idea. The color should be set only once. I would like to be sure that MyPainter paints ONLY with the initialized color. Any default color should ever be used.
For more clarity I provide a sample:
''' <summary>
''' Singleton class MyPainter
''' </summary>
Public Class MyPainter
[code]....
I am normally a c# programmer but am now working in VB for this one project when I use to set up a singleton class I would follow the Jon Skeet model
public sealed class Singleton
{
static Singleton instance = null;
static readonly object padlock = new object();
[code]....
I get StackTracker.Instance.Instance and it keeps going, while it is not the end of the world it looks bad.is there a way in VB to hide the second instance so the user can not recursively call Instance?
I have recently discovered the singleton approach to mdi child forms and I was trying to integrate this singleton stuff into my "mChildform" class but I keep getting InvalidTypeCastException when I do so. Not sure where I am messing this up.
My mChildform class inherits Form and adds a few properties that are required by all child forms. All of my other project forms inherit this mChildform as their base type instead of form.
When I go directly to one of these forms (the logs form for example) and add
[code...]
I get the exact results that I want. Naturally, since this is something I want all child forms to be able to do I try to add it to my mChildform base class.
The code compiles, but since the reference is of mChildForm type I want to cast it to my usable form class, but it throws the InvalidCastException.
[code..]
I'm not sure why I can't cast it to the other form type, but i'm hoping someone here can explain why I cannot. The Instance() check would always fail if I do not cast my instance to another one of the types.
Since my mChildForm class only holds minimal info to do any real work I have to cast it to the other type. As a workaround I can add the instance method to each new form but I would really like to get it into the base class.
Can we configure remoting for the LAN? I studied it halfway but I realised that its for web, but I think it can be possible for LAN too.
View 2 RepliesI am creating a client/server application that connects via .NET remoting and I'm using TCP. I have 2 config file for client and server. The config file and the server application runs good. But for the client, it runs even though the server is offline and no port is open listening. I've gone through quite a lot of example and don't really know whats happening. This is my client config file.
[Code]...
In the Designer of my forms I usually have this for Singleton purposes.[code]Is there any hack in the IDE that would let me just press a button or something and it will automatically add the code I have above to the selected Designer?I can always type or copy/paste/modify it but I thought there could be something that I could set to just automate this redundant task.
View 7 RepliesI am working on creating a customized UI composite control. This control would be a container to several other custom controls.As a first step, i am creating the container UI using a singleton pattern. This is because at any point in time only one isntance of this container is allowed to be created. This is fine.Now i want to practice interface based desgin. So i introduced a sinple interface calleD IdesignSurface which has two properties. I would like my singleton class to implement this interface,so i tried something like this and got an error saying "end of line
NotInheritable
Class DesignSurface
implements IDesignSurface
[code]......
Im trying to Implement the Singleton Pattern and im wondering if this is "Thread Safe" or if I am going to have to explicitly perform a SyncLock on the object instance? Example:
Public NotInheritable Class SingleTon
Private Shared _singleton As SingleTon
Private Sub New()
[Code].....
I tried it both ways, using the SyncLock and without, just not sure which one to be using?
I have an web application written in ASP.NET (FW 3.5) (along with some VBScript, this is a legacy app) that uses a utility class in the backend that logs error. I need to log several values that a user has entered in the front-end. Since the utility class has no access to the front end (or any HTTP services), i created a singleton class within the utility namespace that my front end UI can access and store information about the user.
I guess more specifically, I am wondering if there's a way to store session variables that can be shared across the web application and web services through a class referenced by both of the application and web services. For example, I have an error handling class that is used by both instances that required information about the user. Is there a way to create a per-session singleton to hold that information, so that my error class will have access to the user info?
Reading about singletons classes/pattern gave me a pretty good idea for its use. But would it be a good practice to store user related variables in properties of a thread safe singleton class so i can access them by chaining?
Example
When a user logs in several variables will be assigned to a session variable like:
Session("UserID") = reader("UserID")
Session("AccessLevels") = reader("Accesslevels")
Session("UserName") = reader("UserName")
...
Now when working on my webapplication i could always access these values by calling the session() variable, but the chance to forget the session keys or erroneous write them down is significantly. So again would it be good to store these session variables in readonly properties of singleton class so I can access them like:
MySingleton.ID
MySingleton.Accesslevels
MySingleton.UserName
I currently had a .Net Remoting Application running on Framework 2 under IIS. I have to upgrade it to Framework 4 in order to use some new components. I have been able to set everything up and running smootly on Framework 2, but as soon as I change to Framework 4, I get the following exception when I try to call one of the function of my remote object.
The input stream is not a valid binary format. The starting contents (in bytes) are: 53-79-73-74-65-6D-2E-52-75-6E-74-69-6D-65-2E-52-65
This bug is not the real bug, it is caused by the fact that the remote object is throwing an exception, and IIS wrap the exception in XML, which throws the BinaryFormatter off.See this for more info on the bug.
This is very unfortunate because I cannot see what is causing the exception, and having never used any Remoting before, I do not have much ideas as to where to start debugging. It seems the Exception is thrown before even stepping in the code because I do a fair amount of logging and none of it seems to be triggering.Basically, I'm looking for some clues or pointer from people that encountered similar problems:
What could be causing the exception when no code has changed besides Compiling from .Net 2 to .Net 4?How can I get the full Exception message that is returned?
[Code]...
1)i created remoting server now i want to communicate with that
2)if i want to develop a remoting application how i startadil
I have a server, listening to Remoting request on TCP channel. When first client was connected, it was able to proceed on the lines of code shown in the picture. When a second client connected, it shows this error
View 6 RepliesSo I took this from an example. GetInstance() is called from hundred different places in my program, and when I debug, the line "Prog = New Program" keeps getting hit for each of those calls. Which I thought was exactly what should NOT happen.. Or do I have some fundamental misunderstanding?
[Code]....
It seems the "New" sub triggers a number of calls to Program.GetInstance, before the first one completes. This is due to me earlier having lots of shared public objects in this class, which are no longer shared since the class was made singleton. And these objects, when initialized, calls the Program class for reference to other of it's objects.
I have a table, Users, with a related child table, UserSecurityGroups. In my GUI, the operator would select a user from a list. The program would retrieve the user record and allow the operator to edit the user data in one form. The operator could also edit the UserSecurityGroups of this user on another form.
I am considering using a singleton class for user instance retrieval and persistance back to the database. If this is a good practice, I want to use this with many other tables in my DB. My question is: Is this a good practice? What pitfalls am I missing? What would you recommend as an alternative? Would your recommendation change since I also have tables with three or four levels of relations (as opposed to two in the example above)?
Here is my proposed code:
Imports System.Data.Linq
Public Class UserConduit
Implements IDisposable
[code]....
Implement singleton in a parent class.Infact what I want is that All the childs etc. should use same instance of the parent.
I have implemented singleton, Changed the scope of parent class's constructor to "Protected". But in the application when ever the new child's constructor is called i.e. "Dim abc as New Ch1()" the constructor of Parent is called (as it is Proctected and can be access from child).
I'd like to expose some functionality via a WCF service. I can configure WCF to instantiate a class per-request but am unsure how I can get a reference to a communal singleton if I were to have some functionality to store a list of calls to a method (call it LogMethod) via WCF in memory and return that list when the GetLogs method is called
I'm aware I could use a database/the file system to pass this data back an forth but in many cases, that seems to be overkill. Edit: It seems that nobody has a clear answer - I can't believe this is complex. Am I missing something obvious?
implement singleton in a parent class. Infact what I want is that All the childs etc. should use same instance of the parent.
I have implemented singleton, Changed the scope of parent class's constructor to "Protected". But in the application when ever the new child's constructor is called i.e. "Dim abc as New Ch1()" the constructor of Parent is called (as it is Proctected and can be access from child). Which is undesired behaviour.
Testing a configuration of a Windows 7 workstation acting as a "server" and a Windows XP workstation acting as a "client" (also fails in the same way using a Windows 7 client workstation).
[Code]...
I am working on a .net remoting project (VS 2008). I have a .dll hosted in IIS 6 windows server 2003 r2.
When i try to test it in internet explorer "http:localhost/hellone/test.rem", it shows the following error
System.BadImageFormatException: The format of the file 'SimpleTest' is invalid.File name: "SimpleTest"
at System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Boolean isStringized, Evidence assemblySecurity, Boolean throwOnFileNotFound, Assembly locationHint, StackCrawlMark& stackMark) at System.Reflection.Assembly.InternalLoad(AssemblyNa me assemblyRef, Boolean stringized, Evidence assemblySecurity, StackCrawlMark& stackMark)
[Code]...
I have downloaded an application that uses .net remoting.
The problem is that I don't know how to configure it to communicate over the internet.
From the blog [url] says to set the tcp 192.168.1.100 . As far as I know this is the intranet IP. My external IP is different. Do I need a server or a Static IP from my provider?
I'm using the following code in a singleton remoting object MBRO. This function is only called on the server side.
''' <summary>
''' Return a cached DataCentricObject
[code].....
I am trying to switch from a SingleCall Remoting infrastructue to a client activated object infrastructure. But can't get it to work. Probbaly a setting. On the hosting server (a console application) I have:
[Code]....
When we use Client-Activated Objects in remoting ? can any one provide an example on Client-Activated Objects
View 3 RepliesWe have a client server application that 650 users are using everyday. Lately they have started complaining about over all slow responses and slowdowns in normal application usage like searching, reporting etc.We are using .NET Framework 3.5 and .NET Remoting is the technology we have used for client connection to the server side. We can't remove that and use something else due to legacy application maintenance. We are using SQL 2008 R2 x64 on a very good server.We have gone though the basic steps of making sure that all the SQL side is ok everything is well tuned but we need to convenience the client that it is not the application but the database that needs to be regularly maintained by a DBA in order for it to run smooth due to the nature of the application making tons of changes and inserts in the database everyday.
Anyways I need to write some sort of module that can plugin into the .NET Remoting calls so it can log the normal usage of different methods on the server like;* How many times a remoting method is called* What params a remoting method is called with* How much time it takes to execute each remoting callIs there anything available in .NET Framework that can help me? I read something about .NET Remoting Sync but not too sure if that is what I need to use? If any can shed any light on the subject or nudge me in a right direction with some sample code, that would be great.