.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

TransactionScope - why isn't the persist optional?

Posted By:      Posted Date: April 14, 2011    Points: 0   Category :JQuery

In the case of a WCF WF service, you have a request/reply pair. Between the request/reply the area is known to be a no-persist zone.

Consequently, if you attempt to insert a TransactionScope activity into the no-persist zone, then you will get an error at runtime because the implicit persistence point at the completion of the TransactionScope will fail since the workflow cannot be persisted before the response is sent.  

You CAN write a custom activity, include a standard .Net TransactionScope and insert this into the no-persist zone and this will work fine (as it does not try to "persist"). On that basis, why can't you have a TransactionScope without persistence there too?

The odd thing is, even if you don't configure persistence at all (i.e. no InstanceStore), the TransactionScope will still fail.


View Complete Post

More Related Resource Links

Persist large dataset across ASP.NET pages. No database


Can anyone give me suggestions on how to implement the following requirement?

1. A online wizard (step-by step operation) processes user requests across several ASP.NET pages.  The session data is stored in memory until the user submits the request.  Once the request is submitted, a XML file is created and the data are passed to XML.

# Case Study: The parent page has a "select" button.  Click "select" will pop up a child page.  The users can select 1000+ items from a datagrid in the child page.  Once the user clicks "confirm", the selected items in the child page will be populated to the selected item gridveiw in the parent page.  The user can keep selecting more in the child page and the selected items will be appended to the gridview in the parent page.


- What's the best way to extract strings from a text file and convert to a dataset in memory and then present it in a datagrid in UI?

- What's the best way to persist and manipulate a large dataset across pages?  Session? or ViewState? Can it be accomplished by LINQ?

The app doesn't interact with a DB.  Once the request is submitted, it will convert the in memory data to a XML file.  What technology can be used to accomplished this?&nb

Persist data in a dynamically populated ListBox in a user control


Hi All,

I am trying to persist data in a dynamically populated ListBox in a user control. Here are the details

I have a user control which contains a a listBox and button. On Page_Load of user control I am populating the ListBox control with some values. On Click of button, I am trying to fetch the values which I have selected in ListBox. Though this seems very simple and straight forward I am unable to fetch values.

My Page_Load Function

void Page_Load(object sender, EventArgs e)










My Click Function

Protected Void Button1_Click(object sender, EventArgs e)


       string strValue = listBox.SelectedValue



I have placed brake point at Page_Load and on click function, I am seeing that the moment the breakpoin

How do I persist custom complex types in design-time


Let's say that I've got one custom webcontrol called MyControl.

public partial class MyControl: WebControl {
public IComplex Complex { get; set; }

The control is a very simple control but it holds an instance of a complex type that is accessable through a property. The property has the propertytype IComplex

public interface IComplex {
string Name { get; set; }
List<IComplex> Children {get;}

Let's say that I am able to pick one of several different types of object that derives from IComplex in design-time and assign it to the controls property "Complex" property.

Naturally I would like to persist this information to the HTML-View in a user-friendly way.

Because we don't know what type the user has picked there is no way to instansiate the type if we don't persist the name of that type. The Type could also contain more properties than the Interface the controls property is refering.

<cc1:MyControl id="MyControl1" runat="server">
<Complex> <!-

More Versioning Fun With Optional Arguments

In my last blog post , I covered some challenges with versioning methods that differ only by optional parameters. If you haven't read it, go read it. If I do say so myself, it's kind of interesting. ;) In this post, I want to cover another very subtle versioning issue with using optional parameters. At the very end of that last post, I made the following comment. By the way, you can add overloads that have additional required parameters. So in this way, you are in the same boat as before. However, this can lead to subtle bugs. Let's walk through a scenario. Imagine that some class library has the following method in version 1.0. public static void Foo( string s1, string s2, string s3 = "v1" ) { Console.WriteLine( "version 1"...(read more)

Versioning Issues With Optional Arguments

One nice new feature introduced in C# 4 is support for named and optional arguments . While these two features are often discussed together, they really are orthogonal concepts. Let's look at a quick example of these two concepts at work. Suppose we have a class with one method having the following signature. // v1 public static void Redirect( string url, string protocol = "http" ); This hypothetical library contains a single method that takes in two parameters, a required string url and an optional string protocol . The following shows the six possible ways this method can be called. HttpHelpers.Redirect( "http://haacked.com/" ); HttpHelpers.Redirect(url: "http://haacked.com/" ); HttpHelpers.Redirect( "http...(read more)

Optional named parameters work pretty well

Rob has found a use for dynamic: http://blog.wekeroad.com/2010/08/06/flexible-parameters-with-csharp Yay! Let's celebrate! Well, I was a little puzzled because I don't think it quite adds up in the specific example he chose (although please see no aggressiveness here: Rob's a friend; peace!). The idea is to have the same flexibility that a dynamic language can offer in terms of evolution of an API. Here's his original Ruby example: def my_method(args)   thing_one = args["thing1"]   thing_two = args["thing2"] end my_method :thing1 => "value", :thing2 = Time.now The idea, which is quite common in dynamic languages, is that instead of passing a list of predetermined parameters in a specific order, you...(read more)

persist security info not available by a codebase odbc driver



I want to interface the software Sage ventpartner with sharepoint.

For that i have to use the odbc {codebaseStand} driver and i know that the following string is working :


The pb is when i construct my bdc xml file i have to enter :

        <Property Name="rdbconnectionDriver" Type="System.String">{CodeBaseOdbcStand}</Property>
        <Property Name="rdbconnectiondbq" Type="System.String">c:\ventpart\database</Property>
        <Property Name="rdbconnectionuid" Type="System.String">administrateur</Property>
        <Property Name="rdbconnection Trusted_Connection " Type="System.String">yes</Property>
        <Property Name="DatabaseAccessProvider" Type="Microsoft.Office.Server.ApplicationRegistry.SystemSpecific.Db.DbAccessProvider">Odbc</Property>
        <Property Name="SsoApplicationId" Type="System.String">23</Property>

Optional Parameters - Not taking values when supplied

All, I have a report that takes 2 optional parameters, one int and one datetime. My data tab is set up as follows: CommandType = Text, Parameters has Parameters.Value etc. for both. Report Parameters are allowed NULL value, Default Value is NULL, datatypes are Integer and Datetime as well. This only runs when the parameters are not supplied values, when I enter a date, it does not take it into account, same for the int value. I have run the proc manually to verify that the query is set up correctly, it seems like the values are not being passed? Any help debugging this would be helpful. Thanks.

optional output parameter in CLR Stored Procedure

I'm trying to transpose a Procedure that sends mail via CDO.Message and Ole Automation to a .Net CLR Procedure. this procedure must have the same parameters in the same order as the original to maintain compatibility with everything that already uses it. the declaration goes as follow   <Microsoft.SqlServer.Server.SqlProcedure(name:="SP_ENVIAEMAIL")> _<br/> Public Shared Sub ENVIAEMAIL(<SqlFacet(MaxSize:=100)> Optional ByVal De As String = "", <SqlFacet(MaxSize:=100)> Optional ByVal Para As String = "", _<br/> <SqlFacet(MaxSize:=100)> Optional ByVal Copia As String = "", <SqlFacet(MaxSize:=100)> Optional ByVal Oculta As String = "", _<br/> <SqlFacet(MaxSize:=100)> Optional ByVal Assunto As String = "", <SqlFacet(MaxSize:=-1)> Optional ByVal Mensagem As String = "", _<br/> <SqlFacet(MaxSize:=-1)> Optional ByVal Anexo As String = "", _<br/> <strong><SqlFacet(MaxSize:=1000)> <Out()> Optional ByVal Retorno As String = ""</strong> , _<br/> <SqlFacet(MaxSize:=100)> Optional ByVal Smtp As String = "", <SqlFacet(MaxSize:=100)> Optional ByVal Usuario As String = "",

OPEN SYMMETRIC KEY - Persist Across Sessions

We have a client .NET WPF application which connects to a local SQL 2008 Express server.  We are using symmetric SQL encryption to encrypt some columns.  In order to encrypt or decrypt, we must first open the symmetric key.  We have a logon trigger which opens the key automatically for us. Unfortunately, the key is opened A LOT due to the key being closed after each session closes.  This causes the CPU to peg at 100%.  We are using connection pooling and it would be wonderful to have the key remain open across sessions.  Anyone have any thoughts on how to do this?

How to persist workflow with non-serializable arguments

I have a workflow that has some arguments for underlying components (DAL implementation, email sender etc). It also has a  WCF data contract and other serializable arguments. I need to persist and unload this workflow and then resume later on. It is throwing an exception because it is trying to serialize and persist all the workflow arguments. Is there a way to get the serializer to persist only those arguments that can be serialized?

LINQ and TransactionScope

I have a requirement whereby I either have to perform and update or an insert on 1 table inside a transactionscopeThere are 3 table in total, 2 will always be an insert, but 1 could be either an update or insert depending if some data already existsa foreign key relationship exists between all 3 tables (not on the same column though)heres my codea.DB.DataTable dt = new DataTable(); if (isAlreadyExist) { var updData = (from p in DBContext.Table where p.ID.Equals(ID) select p).SingleOrDefault(); if(updData != null) { updData.LastProcessedDate = some date; } } else { dt.LastProcessedDate = some date here dt.ID = some id here dt.Reference = some reference here } using (TransactionScope trans = new TransactionScope()) { try { DBContext.Table1.InsertOnSubmit(dbObj1); //get the newly inserted id ID = dbObj1.ID; dbObj2.ID = ID; DBContext.Table2.InsertOnSubmit(dbObj2); // here i need to either submi

Silverlight 4.0 Optional & Named Parameters

Named & optional parameters are a new C# language feature coming up with .NET FX 4.0 and guess what. it's in Silverlight 4 as well! Optional parameters will come very useful when defining complex APIs where you would usually have to provide several overloads for the same method for it to make sense to wide variety of usages. Let's take a look at this basic example:public void PositionWindow(bool isTopMost, double left = 0, double top = 0, double width = 800, double height = 600){Window window = Application.Current.MainWindow; window.TopMost = isTopMost;window.Left = left; window.Top = top;window.Width = width;window.Height = height;} isTopMost is the only parameter that's required, all other parameter specify their default value, which makes them optional. But what if you wanted to provide the size only and leave the position to be set to defaults? Enter named parameters. The same method above can be called also with:PositionWindow(isTopMost:true, width: 600, height: 200); // named parametersPositionWindow(true, width: 600, height: 200); // naming is optional when positioned rightPositionWindow(true, height: 200, width: 600); // order doesn't matterPositionWindow(height: 200, width: 600, isTopMost: true); // ... even with the required parameters Simple ... Cheers:)

SPWeb.Properties is not persist over the redirect page.

Hi, I have to pass some object from my code to another redirected page. So I serialize the object and serialized string is save to SPWeb's property as a string and after that I use SPUtility.Redirect('Url'). But on redirected page above updated property is not find in the SPWeb.Property collection. string xml = MyClass.GetXMLFromObject(exInfo); SPContext.Current.Web.Site.RootWeb.AllowUnsafeUpdates = true; SPContext.Current.Web.Site.RootWeb.Update(); if (!SPContext.Current.Web.Site.RootWeb.Properties.ContainsKey("MyInfo")) { SPContext.Current.Web.Site.RootWeb.Properties.Add("MyInfo", xml); SPContext.Current.Web.Site.RootWeb.Update(); } else { SPContext.Current.Web.Site.RootWeb.Properties["MyInfo"] = xml; SPContext.Current.Web.Site.RootWeb.Update(); } SPContext.Current.Web.Site.RootWeb.AllowUnsafeUpdates = false; SPContext.Current.Web.Site.RootWeb.Update(); SPUtility.Redirect("RedirectToErrorPage/ApplicationPage1.aspx?ExInfo=" +xml, SPRedirectFlags.RelativeToLayoutsPage, HttpContext.Current); Redirected page code: if (SPContext.Current.Web.Site.RootWeb.Properties["MyInfo"] != null) { using (SPWeb web = SPContext.Current.Site.OpenWeb(SPContext.Current.Web.Site.RootWeb.Url)) { TextBox1.Text = Convert.ToString(SPContext.Current.Web.Site.Root

WCF DataService : basic Order - OderDetail - Product use case - unable to persist

Hello, I have the very classical Order - OderDetail - Product use case. I've made my database, my entity framework model and exposed it as a DataServices Read/Write. Order, OrderDetail and Product table have a Id column which is a PK based on an IDENTITY column (auto incr) Form the client, I try the following : MyEntities session1 = new MyEntities(svcUri); Order o = new Order(); session1.AddToOrder(o); o.OrderDate = DateTime.Now; Product p1 = new Product(); session1.AddToProduct(p1); p1.ProductDescription = "Product1"; Product p2 = new Product(); session1.AddToProduct(p2); p2.ProductDescription = "Product2"; OrderDetails d1 = new OrderDetails() {Product = p1, Amount = 1}; session1.AddToOrderDetails(d1); o.OrderDetails.Add(d1); var response1 = session1.SaveChanges(SaveChangesOptions.Batch); I receive the following error : Unable to determine the principal end of the 'MyEntities.FK_OrderDetails_Product' relationship. Multiple added entities may have the same primary key. I try to initialize every Id (PK)  of every object I create on the client using temporary values (-1,-2,-3,...) and then I got an other error message : The INSERT statement conflicted with the FOREIGN KEY constraint \"FK_OrdeDetails_Order\". The conflict occurred in database \"MyEntities\", table \"dbo.Order\", column 'OrderId'.&a

Hidden site column shows as 'optional' in created document library

In Sharepoint 2007, I created multiple site content types.  From these I created other content types based on the original site content types.  To these second group of content types I added a site column which is hidden.  I craeted a document library and saved it as a template.  I then created a new document library using teh document library template.  When I then look at the hidden column for the content types in the document library, the previously hidden column in the default content type is now 'optional'.  The hidden column in the other content types is still showing as hidden.  Any clues as to why?  Thanks in advance.

non-exixstent html pages persist and won't die and can't be exterminated


I'm having a rather odd problem with html pages in VWD.

I'm using VWD 2008 Express on my personel home computer with windows XP as the operating system and  developing aplications using  my home computer as the local server.  Also have a web site  server..... but thats not where the issue arises now.

Problem is, when i create a new html page,  a blank page  with typing only on the page, say:

"this is a html page"

save the page with only the above phrase on the page, I can't go back and make any changes to the page.  If i do, no matter how simple the change , all that displays is the original typing.  I also cannot modify or change  any of my much more extensively developed web pages. 

Even  the simplest addition or changes  all lead to the same  result  when I use  View in Browser or use the Start debugging option VWD ignore what ever i did and displays the original HTML  content.

However if I open up the same page using IE or Mozilla Browsers, or upload the HTML page to my webhost server it shows all the changes i made.  So the problem is entirely inside VWD.    Only when i try to view the page in VWD does it appear as if no changes were made, IE/Mozilla show the changes made.

Furthermore this only happen

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend