Authorize.NET Serialize Old Version - vb.net

I have a Website that was built by a vendor, and it is pretty vital.
the problem is that it was built using 1.1 framework and now we need it to be at least 2.0 so the host can upgrade their servers. we have been running this website as a standalone web application so that we didn't have to alter the code to use StateServer Session State.
now that we need to move to the new framework they also want us to use StateServer session state, and I have run into the issue that the Authorize.Net portion of the code is not Serializable.
Where do I start in the Authorize.Net project to make it serializable?
I am looking for the fastest way to get this functioning.
is there a way that I can Serialize the whole object when it is called, I am kind of thinking this is a no from what I understand of how Serialization works.

this was a simple issue, and I was really stressed about it, but it turned out I just had to add <Serializable()> to the Class Declaration of each class so it looked something like
<Serializable()> Public Class ANet
Just like Tim said.

Related

Class Library restrict access

I am using VS2012, Visual Basic and wish to create a Class Library.
Is it possible to restrict access to a Class Library? I am wanting to create a Class Library for the serializing of objects. This Class Library will be included in each of my applications. As such, is it possible to ensure that only my applications can use this Class Library? If so, how do I go about this?
You can make it more difficult but not entirely prevent your library being used in another application.
You can do things like obfuscate the code to make it harder to decompile, and add dummy parameters to the public methods so that it's hard to figure out how to call them.
If someone is really determined, they will find away around whatever technical measures you use. How much effort you should spend on protection, and how much effort anyone would use to get access depends on how valuable the code in the class library is.
If it is really important that no-one can use your class library, set it up as a web service, so you don't have to distribute it.

Adding a COM interface to an existing application (EXE)

I intend to add a COM interface to an existing application (which, by the way, is written in C++ using Win32). I have some experience using COM objects, so I know the basic COM concepts of interfaces, etc., but this is the first time I'm actually implementing a component.
Ultimately I want to be able to use the COM interface to automate my application from scripts such as VB. I understand that there are two steps:
My application must act as an out-of-process server (i.e. I have to use MIDL and generate code for a proxy DLL and a stub DLL).
Once I have the server I can add automation capabilities by implementing the IDispatch interface.
Since the server-in-an-EXE thing with MIDL and what not is already a bit steep, I wanted to get a grasp on all that first before moving on to IDispatch.
I am reading the book "Inside COM" by Dale Rogerson and have completed the chapter on servers in EXEs (the following chapter will cover Automation).
The "Servers in EXEs" chapter provides example code that implements a server and a client. But it is necessary to start the server manually. This confuses me. Obviously, when my application (= server) is used by a client process, this extra manual step should not be necessary. Is there no mechanism to start the server automatically? Or is automation necessary to achieve that? At the moment, the prospect of having to start my server manually (once I even have one) makes me doubt I am moving in the right direction.
Hopefully someone with more knowledge of this can see what information I'm missing and point me in the right direction.
No, COM servers are not normally started by hand. Not sure why the book proposed it, possibly because it wanted to avoid talking about the registry keys you need to allow COM to automatically start the EXE. It isn't otherwise very complicated, you register the Application coclass of your app with the LocalServer32 key value giving the path to the EXE.
It is however not completely uncommon, especially with an existing program. One design decision to make is whether you let the client code completely control your program. Or if your program already has an existing user interface but you also want to expose services to other code. In the latter case it makes sense to let the user start the app by hand, like she'd normally does.
When your application is registered as LocalServer32, it will be invoked with the commandline specified there if no running process has registered a factory object for your CLSID yet.
This way, you can get the best of both worlds -- if the application is running already, this instance can provide the server side, and if it isn't, it will be started.
Automation is completely orthogonal to that -- your component becomes Automation compatible by implementing IDispatch.

Flash Builder 4.5 for PHP does not generate CRUD php classes for services while the previous version did?

I recently upgraded to Flash Builder 4.5 for PHP since I’m working on a big PHP/Flex project and thought that it would be easier to integrate the two.
What do you know? The feature that generate the php class to feed a flex/PHP service trough AMF is appears to be missing!
Time to downgrade or am I overlooking something?
I believe it's still there, but that feature should only be used for building a test application. It breaks a lot of best practices such as creating the connection in the class (it should be injected or retrieved from an outside class that manages the DB) and it puts the database definition info in the class (username, password, etc.). I believe that when you use that feature that a popup tells you that it is not intended for production use. When building a service class it is best to define your classes based off of the functionality you need to provide.

Place Connection String in Model or GUI

I have a VB.NET 2010 solution, that contains 2 projects, a class library and a Windows Forms Application.
The class library basically is a model, used for doing database integration.
I currently have the connection string placed in the class library project settings, but they do not seem to be listed anywhere in the config file of the application. What's the best practice for retrieving the connection string in the class library? I don't want to use a singleton. Should it be stored in the application or class library?
It seems the Class Library would make more sense since that is project interacting with the database. It would probably be beneficial to encrypt the connection string and store it in a file or registry key so that way if the system is compromised, the intruder will still have to crack the key to view the connection string, yet still offers you the ability to change it without recompiling your app.
I still go with what I said in your earlier question - leave the settings/configurations out of the class library. Put them in the config file for the application(s) that use the class library.
What happens if the connection string changes? Since class library's don't use config files, you'll most likely have to update the code, recompile, and redeploy it. Not a big deal if it's one program on one machine, but what if it's multiple programs and/or multiple machines?
Granted, you'd still have to make a lot of changes in a multi-program/multi-system environment via the config file, but that's a lot simpler, IMO, than recompiling (and regression testing) a class library.
Another factor to consider is what if different applications want to use this same class library? What if you have different environments that have different connection strings? And so on.
In a nutshell, I would opt to leave configuration items for the application, not the supporting class libraries. From a resusability and scalability perspective I feel that gives you the most bang for your buck.
If you only have one application and its only ever going to use this one class library, and no one else will, you can probably leave the configuration settings in it - but using the phrase "We'll never change" or "It will always be like this" is a good way to get a lot of headaches down the road.
All of the above is, of course, in my opinion, and should not be taken as me speaking officially for any other programmer or corporation :)
Edited to add
You'll have to manually move the settings you need from the class library's config to the application's config. VS won't do it for you.
And why do you keep bringing up the singleton design pattern? What potential benefit do you see from it? Or have other people been suggesting it to you?

Where to open and close the NHibernate ISession in a web app (specifically MVC)?

This is a pretty fundamental question when using NHibernate in a web application, but I don't see any agreed best practice when searching the web. I've seen it done in lots of different places:
Created and disposed in the Repository method - This just seems silly to me, since when you get the object it's already detached.
At the beginning and end of the Controller Action - This seems better, but annoying to have to do it for each action.
At the Application level, in global.asax beginrequest and endrequest - This seems the best idea, but again, I've seen some examples creating in Init instead of beginrequest (sharp architecture for instance) - although I am not sure why.
Maybe there are other approaches?
Can IoC containers help in some way here?
Maybe you know of a good resource on the web regarding this?
And - what method do you use?
Thanks
Session per Request is probably the most used approach.
I've seen some examples creating in Init instead of beginrequest (sharp architecture for instance) - although I am not sure why.
In IIS 7 You can have access to the Session state in the Init event of Global.asax. That's why sharp arch uses beginrequest.
As for session management I agree with you - Global.asax is the best place for it. Event if you want to have a clean separation between layers and remove DAL settings from UI you can use HttpModule for it.
Also you can have a look at ayende's blog. It explains his way of session management