.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

How to validate XAML which is coming in string variable

Posted By:      Posted Date: October 03, 2010    Points: 0   Category :WPF

I have written following code to validate XAML for duplicate name of controls. But it is not good way of doing because I am using Try for validation.

Please suggest me some good way of validating XAML.


bool validateXAML(byte[] imageFileToOpen)

            if (imageFileToOpen != null)
                MemoryStream mysr = new MemoryStream(imageFileToOpen);
                StreamReader memoryReader = new StreamReader(mysr);

                string xamlString = memoryReader.ReadToEnd();   //String of Xaml code
                memoryReader.BaseStream.Seek(0, SeekOrigin.Begin);

View Complete Post

More Related Resource Links

label concentation with a string variable


I am trying to do something as simple as this in visual studio.net

double num1 = 2;

num1 = num1 * 2;

 Labe1.Text = "The result shown is" & num1.ToString();


but I keep getting the error message operator '&' cannot be applied to operands of type 'string' and 'string'

query string or session variable or neither for this scenario?

Hello,example scenario: user login has a list of associated 'accounts' it has access to... this list of accounts is stored in a database table, say tblAccountAccessControl, something like:login, accountID-----------------------userA, account123userA, account456userA, account798userB, accountABCuserB, accountDEFetc..this info is used throughout the web application and determines the 'domain' of information the particular login has access to. For example there are many other tables that have the 'accountID' field and whenever a page pulls data from the table it only pulls data that the currently logged in user should be allowed to see, based on that tblAccountAccessControl data.the security question:1) do I need to query the database every time I need to get this list of allowed accountID's? I was about to use a plain old query string to pass a particular accountID to another page but quickly caught myself as I realized that would be a major security flaw (the receiving page was going to use that accountID to grab info from the database, and there would be nothing preventing a user from simply typing in a url manually to get data from an accountID they are not supposed to be allowed to view). So I then thought I'll just store the list of accountID's in a session state variable so they will be carried with the user throughout the sessi

What type variable can I use to assign a possible Null or a string to?



I am converting a VB6 app to VB2008 and are having problems with replacing Variant variables.

I used Variant in cases where the data might be string or Null.

Is there a way I could check for Null and just set the string to zero lenght?

Any help would be appreciated.



how to trim a string value of a workflow variable using SharePoint designer.


I build a custom workflow using SP designer and have a need to trim a string value of a workflow variable. I tried using Calculation or Dynamic String builder but without success.

i store a user name type value into workflow variable called  check_name_var (string type). the logon name have this format  domainname\first_lastname 
how do i trim this value in check_name_var to only first_lastname.

Can anyone show me how or have suggest on how to accomplish this or is it possible to do this in SP designer?

Thanks for your help

How to convert string variable to url?



 I need to convert a string to http url.

The way i have to do this is--I have to retriew a value from database and convert it into a sharable http url in Asp.net C#.


I am new to this concept,Can anyone help me.......................

How do you specify an empty string in XAML?



For an application I am working on, I am keeping some of the strings for the UI in a ResourceDictionary, which is defined in XAML, like so:


<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlnsTongue Tiedystem="clr-namespaceTongue Tiedystem;assembly=mscorlib"

    <systemTongue Tiedtring x:Key="String1">String 1</systemTongue Tiedtring>
    <systemTongue Tiedtring x:Key="String2">String 2</systemTongue Tied

Error: The variable System::ErrorDescription contains a string that exceeds the maximum allowed leng


i get the following error message, when I try to email the error description, by invoking a 'Send Mail Task' in OnError event.

"Error: The variable System::ErrorDescription contains a string that exceeds the maximum allowed length of 4000 characters."

Any idea how to resolve this issue? I am using substring when I build the expression. But still am facing this issue.

How do I recover xml from an SSIS String variable?


When I get my resulting xml from a webservice task, the response is not only well formed, but actually valid. When I put it into a string variable for passing it along to the next task in SSIS, the XPATH against it in the XML task it fails because what happens is the XML got munged as it went into a string. All the quotes got escaped and all the linefeeds and newlines ended up as \r\n, etc.

Is there a way to avoid this or recover from this without having to save the xml to file and then load the xml from the file for the next task?


How do I write a string coming from a Javascript function in my Label control?


Hi all,

This is what I tried doing in my Javascript function (partially):

catch (err) {
              document.getElementById("lblError").innerHTML = err.description;

IE output of my lblError label component is a long id name like this:

<td>Last Error: <span id="ctl00_ctl00_ContentPlaceHolder_GlobalMasterPage_ContentPlaceHolder_DashboardMasterPage_lblError">No errors at this time.</span>

how do I look up for lblLabel in this case?

Thank you

Failing Connection String Environmental Variable, XML Variable, System Variable (SQL Server) Setup


We attempted to implement the Chapter 2 Framework from the Knight, Vermeen, Moss, Hackney book on SSIS 2008: Problem Design Solution. We see a couple of problem areas (at least) in our interpretation of the guidelines from the book.

1. We are attempting to have one connection string per server: dev/prod

2. We have set up environmental variables per server: dev/prod

3. We have set up XML Package Variables per server: dev/prod

4. We have set up System Variables per server in SQL Server: dev/prod

Problem 1:

We've had to manually key in the common connection string to all packages on a server environment in the component properties area (control flow; not data flow--ok there)

Shouldn't the connection property find the connection that we've instantiated and provide us with a pull down to select it?

The components are un-editable after we select the common connection string, but they still run properly in our SQL Server Agent Job.

Problem 2:

The dev server variable overlays the prod server variable information duringprod component editing

We are'nt sure if these problems are related.

Here is our package variable:



Here is our DTSconfig file; we have a few variations of this that we've tried.

Date to String Conversion in SSIS Variable


Hi All -

I have an SSIS variable whose value is a date formatted as a string in YYYYMM. For example 201011 (meaning Nov 2010). I need to change the value to 201012 (meaning Dec 2010). My thought was to convert 201011 to a date, use dateadd, then convert back to a string. Something like:

(DT_STR)DATEADD(mm, 1, (DT_DBDATE) @[User::strVar] + '01'), 6, 1552)
Can someone point out what I am doing wrong?

Class to discover if a string is a legal variable name


Does a class exist to verify that a string contains a valid variable name. I am generating code based on user input and need to verify it.


ie: First character is [_a-Z], followed by up to 'n' [a-z0-9_] and is not a reserved word, now or in the future.

I think I could do it via reflection and compiling it, but that seems a bit heavy-handed.

I would also prefer if I could exclude legal names like 'var' and 'partial', 

Paul Cotter

Resultsetmapping does not work, if the SQL string comes from a variable


Hi guys,

I use SQL 2005 (9.00.4273) and I'm a little bit disappointed because of a strange error.
I have an ExecuteSQL Task where I pass the Query-Output to some variables.

If the SQLSourceType is a "Direct input" all works fine.

Unfortunatly I have to use "Variable" for SQLSourceType because I have to pass a parameter to the SQL String.

The string looks like this

with cte as (
SELECT PropertyScope, PropertyName, PropertyValue
FROM PropertyList 
where PropertyGroupSub = 'DTS'
SELECT SP, ISNULL(SP_Server,'Default') as SP_Server, ISNULL(SP_Catalog,'Default') as SP_Catalog FROM
SELECT propertyscope, PropertyName, PropertyValue FROM cte
where PropertyScope = isnull(nullif(cast('100102010' as varchar(50)),'999999999'),'Default_SYSTEM_IMPORT')) p
FOR PropertyName in (SP, SP_Server, SP_Catalog)
) AS pvt

In the Variable it looks like
"with cte as (
SELECT [PropertyScope], PropertyName, [PropertyValue]
FROM PropertyList
where [PropertyGroupSub] = 'DTS'
SELECT SP, ISNULL(SP_Server,'Default') as SP_Server, ISNULL(SP_Catalog,'Default') as SP_Catalog FROM
SELECT propertyscope, PropertyName, PropertyValue FROM cte
where [PropertyScope] = isnull(nullif(cast('" +  @[User::ProcessID]  &

Application variable or static class for global string?


I need to keep a global variable throughout the whole time the user is at my site, but do I use Application or a static class? The string variable should store a region name and my site makes a few changes depending on which region that has been set.

I read that Application was mainly for classic ASP, but I also read that a static class cannot be instantiated at runtime (e.g. when the user has logged in).

So, have I got something wrong here and which solution do I use?



How to show property string of a suboject in XAML


I have this situation: a listbox that contains a source to a collection of objects (ItemAll).

This ItemAll, have at the same time, an object name layout that haves title and imageURL.

This is my XAML of the itemsource of the listbox:

<Grid HorizontalAlignment="Stretch">


Is it possible to interpet a string name as variable name

I have 25 DataBase fields within my DataRow called MyFieldVar1, MyFieldVar2, MyFieldVar3 etc....
Is the following possible
String sTest=""; For (int I=0;I<25;I++) { sTest += oDR.MyFieldVar&I; }
Or would I have to code:
sTest += oDR.MyVar1;
sTest += oDR.MyVar2;
sTest += oDR.MyVar3;

Passing a SSIS Variable with a string datatype to a Stored Procedure requiring a uniqueidentifier


I have a SSIS package that uses a SQL Server stored procedure as a data source. The parameter in the stored procedure is pulling data from a column with a uniqueidentifer (guid) data type. I created a package level variable in SSIS with a string datatype. SSIS variables do not offer a uniqueidentifier datatype.

I have the following text in the SQL Command text box:

exec dbo.spBillingReferenceSource
@BatchID = ? 

When I click the parameters button the mappings are @BatchID for the parameter (which is the exact name of the parameter in the stored procedure) and User::BatchID (the SSIS variable) 

When I run the stored procedure in preview mode in the SSIS dataflow, it returns an error message -- "No value given for one or more of the required parameters"

If I run the stored procedure by typing the value in the datasource box such as listed below, it works and delivers the proper records. I have even modified the stored procedure to convert the column to use varchar(36). However, it still returns the same error message. Does anyone have any suggestions on how I can get this to work. Thank you.


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