473,657 Members | 2,414 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Managed wrappers in ASP.NET Session

Hi,
Is it safe to put my objects that are managed c++ wrappers to the
session? I want to pass them from one page to the other in the session
object but I noticed strange (maybe it is ok) behaviour: sometimes
destructors from unmanaged classes (that are being wrapped by my
wrappers) are called when it's not needed.
Thanks in advance for any suggestions.

Regards,
mirek

Nov 17 '05 #1
8 1380
Hi,

Basically yes, but make sure that the unmanaged code isn't STA (probably
not if you wrote it in C++).

Personally I don’t like to use the session and in particular not to
store objects in the session. Can you share with us why you need to do
it ?
if you just need to pass them between pages that use transfer to
navigate between them you can use Context instead of session.

Natty Gur[MVP]
Phone Numbers:
Office: +972-(0)9-7740261
Fax: +972-(0)9-7740261
Mobile: +972-(0)58-888377
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 17 '05 #2
Hi,
Thanks for your reply.

Natty Gur wrote:
Personally I don’t like to use the session and in particular not to
store objects in the session. Can you share with us why you need to do
it ? We've developed desktop appliaction in C++ (MFC) and fortunatelly we
separated code to have "business objects" classes in C++. Now we are
trying to implement web interface using ASP.NET and wrapping our
business classes to Managed C+ to be used on ASP.NET pages.

The first need was to store our user object (from business layer) in the
user's session so we could get user details, specific permission and
many other user's data on every page. Finally as there were problems I
was talking previuosly I've implemented global map where are put these
user objects (the session id is the key of this map) and it seems to
behave correct. (Also one advantage of this is that I am able to list
logged users or restrict that one user can only have one session.)

Another use of object in session is when I have multi page editing
(something like a wizard). On the first page I create my business
object, on submit I fill it with field values and pass it in the session
to the next page.
if you just need to pass them between pages that use transfer to
navigate between them you can use Context instead of session.

You mean Server.Transfer ? It would be ok but I don't like that the url
isn't updated in the user's browser. It could be quite confusing for him
and refreshing a page isn't possible.
Reagrds,
mirek

Nov 17 '05 #3
Hi,

I think that if you will break your program into 3 layer (Visualization,
Business logic, Data) you can prevent from saving object in the session.
in such application you will need just to save data of your users in the
session / application and you can use BL objects just to Process and
handle the data. You actually done it by using global map but you save
the data with the logic and I would recommend separating them. Behind
software design perspective of separating data from logic you can see
advantage of that approach in busy web application where thousands of
users hit the server. In that case there will be hundreds of Objects in
the map that increase the server memory usage. But if you will store
just the data in the session and separate object will be use to enforce
logic rules on that data you will end up with less objects and memory
usage.

Natty Gur[MVP]
Phone Numbers:
Office: +972-(0)9-7740261
Fax: +972-(0)9-7740261
Mobile: +972-(0)58-888377
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 17 '05 #4
Hi,

I think that if you will break your program into 3 layer (Visualization,
Business logic, Data) you can prevent from saving object in the session.
in such application you will need just to save data of your users in the
session / application and you can use BL objects just to Process and
handle the data. You actually done it by using global map but you save
the data with the logic and I would recommend separating them. Behind
software design perspective of separating data from logic you can see
advantage of that approach in busy web application where thousands of
users hit the server. In that case there will be hundreds of Objects in
the map that increase the server memory usage. But if you will store
just the data in the session and separate object will be use to enforce
logic rules on that data you will end up with less objects and memory
usage.

Natty Gur[MVP]
Phone Numbers:
Office: +972-(0)9-7740261
Fax: +972-(0)9-7740261
Mobile: +972-(0)58-888377
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 17 '05 #5
Natty Gur wrote:
I think that if you will break your program into 3 layer (Visualization,
Business logic, Data) you can prevent from saving object in the session.
in such application you will need just to save data of your users in the
session / application and you can use BL objects just to Process and
handle the data. You actually done it by using global map but you save
the data with the logic and I would recommend separating them. Behind
software design perspective of separating data from logic you can see
advantage of that approach in busy web application where thousands of
users hit the server. In that case there will be hundreds of Objects in
the map that increase the server memory usage. But if you will store
just the data in the session and separate object will be use to enforce
logic rules on that data you will end up with less objects and memory
usage.

Yes, I know that the best would be make the layers you mentioned or
implement from scratch but unfortunatelly I haven't got enough time (who
has it? :)).
You said that you would store _data_ instead of objects in the session.
Could you explain it more or maybe small example. If I want to store
user data to the session so it would be accesible from every page, I'd
have to store in session following example values: permission="qwe rty",
contacts=[ArrayList of contacts], last_login_date ="28/01/2003", etc? I'd
say it's quite messy. The best would be "User" data object with
properties stored in the session on login, and then retrieved on every
page. Is my thinking OK? :)

Regards,
mirek

Nov 17 '05 #6
Natty Gur wrote:
I think that if you will break your program into 3 layer (Visualization,
Business logic, Data) you can prevent from saving object in the session.
in such application you will need just to save data of your users in the
session / application and you can use BL objects just to Process and
handle the data. You actually done it by using global map but you save
the data with the logic and I would recommend separating them. Behind
software design perspective of separating data from logic you can see
advantage of that approach in busy web application where thousands of
users hit the server. In that case there will be hundreds of Objects in
the map that increase the server memory usage. But if you will store
just the data in the session and separate object will be use to enforce
logic rules on that data you will end up with less objects and memory
usage.

Yes, I know that the best would be make the layers you mentioned or
implement from scratch but unfortunatelly I haven't got enough time (who
has it? :)).
You said that you would store _data_ instead of objects in the session.
Could you explain it more or maybe small example. If I want to store
user data to the session so it would be accesible from every page, I'd
have to store in session following example values: permission="qwe rty",
contacts=[ArrayList of contacts], last_login_date ="28/01/2003", etc? I'd
say it's quite messy. The best would be "User" data object with
properties stored in the session on login, and then retrieved on every
page. Is my thinking OK? :)

Regards,
mirek

Nov 17 '05 #7
Hi,

User data object is just fine :-) (You can use DataTable) as long as you
take in account the memory consequences of storing object that consume X
bytes * Y users.

Natty Gur[MVP]
Phone Numbers:
Office: +972-(0)9-7740261
Fax: +972-(0)9-7740261
Mobile: +972-(0)58-888377
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 17 '05 #8
Hi,

User data object is just fine :-) (You can use DataTable) as long as you
take in account the memory consequences of storing object that consume X
bytes * Y users.

Natty Gur[MVP]
Phone Numbers:
Office: +972-(0)9-7740261
Fax: +972-(0)9-7740261
Mobile: +972-(0)58-888377
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 17 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1942
by: Marek Malowidzki | last post by:
Hi all, I am writing a component that exposes a C++ library as a .NET component. The approach is somewhat automatic: every library C++ class has its managed C++ counterpart that keeps a pointer to the unmanaged class instance. As usually in such a scenario, the IDisposable/Dispose()/Dispose(bool) pattern should be used. The problem is that in my approach it is often impractical, as the library's unmanaged objects are quite small and
3
3586
by: Francis Urquhart | last post by:
I am trying to find the simplest possible way of writing a GUI to run on top of a standard C++ library written in VC++. I would like to avoid MFCs, COM, and if possible .Net wrappers. The goal is just to be able to demonstrate the capabilities of the library, rather than create a finished product. I have read things here and there about "managed code", where you can write a GUI in C# to interface with C++ "unmanaged" code. However,...
3
2210
by: mirek | last post by:
Hi, I've got problem building managed class library to wrap unmanaged code. I created managed class library using standard patten: #include "../Unmanaged/Class1.h" //Class1 unmanaged namespace ManagedWrappers { public __gc MClass1
4
9863
by: Tim Menninger | last post by:
Just started working on this and have not found any real good resources out there. We have a lot of native C++ Dll code that we use for our app. We want to share the code so that C# ASP.net code can use the same business logic as our C++ client. Here are some questions: 1) Is there a way to call into native C++ classes directly? Meaning we do not have C API. I believe we could use a C API using the in C#. 2) If can't do #1, do we need...
7
6929
by: Salvador | last post by:
Hi, I am using WMI to gather information about different computers (using win2K and win 2K3), checking common classes and also WMI load balance. My application runs every 1 minute and reports the status of the machines. Upon we follow the .NET object lifetime recommendations the application is constantly consuming more memory! The problem is on the ManagementObjectSearch, upon we Dispose the object it seems that is not releasing the...
1
6877
by: TC | last post by:
Every time I open my project, I get a warning which says "There are updated custom wrappers available for the following referenced components: Office." When I double-click on the warning, I get a dialog box which says "One or more custom wrappers for COM components have been installed on your machine after you added references to those COM components. These wrappers may provide additional capabilities not offered by the auto-generated...
6
1625
by: Vijay | last post by:
Hi, I am faced with the following common managed/unmanaged C++ interop problem: - I have a .NET form that acts as a front end GUI to a processing engine in the background. The processing engine runs as a thread that is managed by the front-end form class. - The processing engine must have a callback mechanism to update the form about progress, and to send status messages that will be displayed
1
2891
by: stillh2os | last post by:
Hello. I'm new to .NET, and I'm trying to implement a callback function. I want my managed C++ code to call an unmanaged function, passing in a callback function that the unmanaged C/C++ code will call. I'm getting Error 2664: cannot convert parameter 1 from CallBack __gc * to CUSTOM_HOOK_CALLBACK_FUNCTION. Here's what I have... In my unmanaged DLL -- Header file: --------------------------------------------------- typedef VOID...
5
6345
by: Maxim | last post by:
Hi all, I'm calling a COM Interface method that returnes SafeArray wrapped into variant. Is it possible to convert it to managed array? Because working with SAFEARRAY directly is a bit complicated. Or maybe there is a managed wrapper class for safe array? Thanks in advance.
0
8315
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8829
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8734
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8608
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6172
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5633
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4164
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
1962
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1627
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.