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


Top 5 Contributors of the Month
MarieAdela
Imran Ghani
Post New Web Links

.NET Matters: Restart Manager and Generic Method Compilation

Posted By:      Posted Date: August 21, 2010    Points: 0   Category :ASP.Net
 

This month Stephen Toub answers questions pertaining to the Windows Vista Restart Manager API and generic method compilation.

Stephen Toub

MSDN Magazine April 2007




View Complete Post


More Related Resource Links

how to get a class reference as a reference and not a string to send for a generic method

  
I got some property that i get using generic method, there for I dont have it's <T>and I want to send it to another generic method but , how the heck do I get it's <T> :P?please look at the code below to understandit gets an entity framework objects, scan all it's properties and if the property is another entity framework object it would send it back to him self , the issue is that i dont know the new object <T> to send it back to him self :(search for the bold part to see what i'm missing//contains objects which we added so there wont be double adding private List<object> _addedObjects; public FakeGenericRepositoryExtension() { _addedObjects = new List<object>(); } public void Create<T>(T entity) where T : class { //add to created objects _addedObjects.Add(entity); //do something with object //... //start recircle process Type entityType = typeof(T); //run thrue each member of Type foreach (var member in typeof(Type).GetProperties()) { //get member value var member_value = member.GetValue(entity, null); //if not null //we must test this otherwise we can't get .BaseType if (member_value != null) { //get current member's base type string memberBaseType = member.GetValue(entity, null).GetType().BaseTyp

help passing generic list to method

  

I have several lists in one class. When I add an class/object  to a list I want to be able to check if it doesn't exist already in the list. I've done this using a method that checks the particular list individually but would require a method for each list eg


private bool checkShipList (List<Ship> ship, Ship newship)
{

//check list code

}


How can I make it so I use only one method for all lists and can pass the new object to it to check. I used List<T> in the method but can't get it right with the second parameter. Thanks for any help.




could not find a non-generic method 'DeleteProduct'

  

Code:


<asp:GridView ID="ProductsGrid" runat="server" AutoGenerateColumns="False" DataKeyNames="ID,UserId"
            DataSourceID="ProductsOptimisticConcurrencyDataSource"
            OnRowUpdated="ProductsGrid_RowUpdated" AllowPaging="True" AllowSorting="True"
            EnableModelValidation="True">
            <Columns>

                                       <asp:CommandField ShowDeleteButton="True" ValidationGroup="InsertValidationControls" />
                <asp:BoundField DataField="ID" HeaderText="ID" SortExpression="ID"
                    ReadOnly="True" InsertVisi

Calling a Generic WCF method

  

Hi,

We are working with Silverlight 4 using Silverlight enabled WCF Services in VS2010, I'm using LINQ to SQL as well.
We are trying to put security inside our WCF service, we decided to use a method that validates a key inside the WCF when you try to call the WCF Service from outside our application.

We already have all methods, now we need to apply the security, my question is:

Is there any way to call a method that validates something and then returns a kind of generic object to be able to cast it to the correct one after validation? for example I have 20 services already done, I need to add something in my code for each method to validate my key and depending of the return value, return a generic object. Can I do this?

Thank you. 

 


Executing method of the Generic class using Reflection.

  

Hi.

I have a generic class:

 abstract public class BaseTC<T>:IExecutable where T : Core, new()
  {
    private Type2 testInfo;
    private Type1 settings;
    private T core = null;
    ..
}

and I want to load such class from library the class is located in, and create an instance of it and execute methods later on.

I know how to use non-generic classes, but no idea how to call the same with generics.


The AcquireConnection method call to the connection manager "Excel Connection Manager" failed with e

  

I have deployed my packages into Sql Server and I am using Configuration File. As my Data Source is Excel, I have changed the connection string during deployment with Server Path. But I am getting the following errors. Actually the File Exist in Path. May I know What is cause of the issue? Do I need to give any permission to execute the package.

 

SSIS Error Code DTS_E_CANNOTACQUIRECONNECTIONFROMCONNECTIONMANAGER.  The AcquireConnection method call to the connection manager "Excel Connection Manager" failed with error code 0xC0202009.  There may be error messages posted before this with more information on why the AcquireConnection method call failed. 

 

component "Excel Source Service Contract Upload" (1) failed validation and returned error code 0xC020801C. 

One or more component failed validation. 

 

There were errors during task validation. 

DTS_E_OLEDBERROR, Error Code: 0x80004005 Source: "MS JET DB Engine" Description : Path is not valid


 


Can generic types be used as WCF method parameters?

  

Hello everyone, help me plz with one question...

If it`s possible, i would want to know some way for passing generic type as income parameter of WCF service method. In fact, i want pass a lambda expression to use it for filtering data on next tier of application. It`s needed for my own realization of custom paging data on web page, i have already found the way to pass custom SortExpression and SortOrder (and create in other place lambda expression from then for using in OrderBy/OrderByDescending). ALso i have founded the way to pass to web application only one, exactly needed page of data with full illusion of large collection objects, than also supports sorting. The last thing want is to add possibility of filtering data, and for this task it would be great to create lambda expression and pass it to the next tier for using in Where() expression before my other actions for custom paging.

I created generic datacontract that contains property of type System.Linq.Expressions.Expression<Func<TSource, bool>>, and used if as a parameter of wcf method as MyDataContract<MyCustomType>. Project compiles well, even starting (it`s a wcf service hosted in application and installed as service), but i cannot update service reference to it, it shows "The server was unable to process the request due to an internal error" page. I think, may be some prob

The AcquireConnection method call to the connection manager "Excel Connection Manager" failed with e

  

Hi,

I am running package from my local system through Visual studio, It is running perfectly, even I created job and ran the job it is running fine

but when I have deployed my packages into production Sql Server and I am using Configuration File & running package from Job. As my Data Source is Excel, I have changed the connection string during deployment with Server Path. But I am getting the following errors. Actually the File Exist in Path. May I know What is cause of the issue? Do I need to give any permission to execute the package.

"[EXL SRC [1]] Error: SSIS Error Code DTS_E_CANNOTACQUIRECONNECTIONFROMCONNECTIONMANAGER.  The AcquireConnection method call to the connection manager "Excel Connection Manager_PAM" failed with error code 0xC0202009.  There may be error messages posted before this with more information on why the AcquireConnection method call failed."

Component "Excel Source Service Contract Upload" (1) failed validation and returned error code 0xC020801C. 

One or more component failed validation.

I got this ans which is applicable when running package from Visual Studio.

Ans when running from Visual Studio:

Go to Project Properties->Configuration properties-&g

Generic WeakEvent Manager & Listener

  
thought it will be useful,
 
you can use it like this:
 
 
 lsnr = new GenericWeakEventListener<MyControl>(Handler);
 GenericWeakEventManager<MyControl>.AddListener(MyControl.ClickEvent, _mc, lsnr);


 private void Handler(object sender, RoutedEventArgs e)
 {
 Debug.WriteLine("Clicked!");
 }

 

which is like doing
 
_mc.Click += Handler
 
Just that it prevents the memory leak by using microsoft weak event pattern
 
when you make your controls
 
without you needing to implement one of your own

for other routed events in to control create another listener like this:
lsnr2 = new GenericWeakEventListener<MyControl>(Handler2);

GenericWeakEventManager<MyControl>.AddListener(MyControl.Click2Event, _mc, lsnr2);
 which is like:
_mc.Click2 += Handler2;
|
|
|
here is the

Thinking about new C# method prototypes: object as dictionary

  
I recently had to write a small Flickr API. I know many .Net API for Flickr already exist but I needed one for a Silverlight application. Whatever, it's only about building some querystrings so I did it by myself. It's been an opportunity to think again about a classical question: how to pass parameters to a method ?

Imagine you have a generic method to call some Flickr functions.

Creating a Generic Entity Framework 4.0 Repository

  
With .NET 4.0 right around the corner, I thought it would be cool to download Visual Studio 2010 beta 2 and start playing around with the next release of Entity Framework.

The initial release of Entity Framework came with a great deal of criticism. To make matters worse, there was a large uproar when it was rumored that Microsoft would be abandoning LINQ to SQL, in favor of Entity Framework. This was because, at the time, many developers felt Entity Framework was an inferior technology to LINQ to SQL. To set things right, Microsoft proactively moved forward with improving Entity Framework, in time for the 4.0 release of the .NET Framework. This is good news because my initial impressions, so far, have been nothing but positive.

A Generic Dialog ViewModel

  
I worked on a wpf viewmodel for dialogs, because it seemed strange to me that you needed for instance windows forms dialogs to open or save files in wpf. So I set about creating my own wpf dialogs. After creating the dialog viewmodels there still remained a small issue with the library and also I didn't have much time to write an article about it. I however published the library containing the viewmodels for dialogs with another article on my blog

Format Generic List Bound to Gridview

  

I have a generic list of a custom type. The custom type has a string and double.

I'm binding the list to a gridview and it outputs everything fine.

I'm trying to format the double column into a currency format. It is in a template field as I'm calculating a running total. I pass the value to a function that returns a double and adds the current value to a running total which I will show in the footer.

The format is not changing to currency as expected when using String.Format("{0:c}", GetTotal(Convert.ToDouble(Eval("Amount"))))


Any ideas on what might be going on and how to fix this?

Thanks!


Sys.Net.WebServiceFailedException: The server method '' failed with the following error:

  

 Hello...

Let's say we have 2 time consuming functions, aaa and aaa1 inside a aspx page.

[WebMethod]
        public static string aaa(int i)
        {
            Thread.Sleep(1000);
            return i.ToString();
        }

        [WebMethod]
        public static string aaa1(int i)
        {
            Thread.Sleep(1000);
            return i.ToString();
        }

 

 

<div>
        <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true">
        </asp:ScriptManager>
        <span id="displayspan"></span>
        <br />
        <input type="button" value=

Jscript error: Object does not support property or method

  

 Hi, i have little knowledge on javascript but i need to use this code get from somewhere for a jquery to work.

I face this "Jscript runtime error: Object does not support property or method" whenever im trying to run this page.

In my experience, im get this error msg 9 out of 10 times i use javascript in my system.

Im using Microsoft Visual web developer 2008, i wonder if this is related to my problem, i not sure there is anything i need to add as reference or update anything.

But anyway, in short, i just couldn't use javascript code when using this development tool because of this sort of error.

Anyway, it happen that last time i tried use the same type of jquery code in another project and it seems to work well without an error.

But now when im try to use it again in this recent project i created, it come out with this error and i have no idea how to solve it even look through google and this forum.

It doesn't really seems like its the code problem itself although im not sure, because any javascript code just couldn't work.

So below is my code that i need to use.

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" ></script>
<script type="text/javascript" src=&quo

Using CreateNewUserWizard SendingMail method to email me, not applicatnt.

  

I have staff area of my site I am protecting with forms authentication using c# and .Net 4.0. What I want to do is let the staff members register on the site but instead of the confermation email being sent to them I want it sent to me so I can go in and approve it. I have been trying to use the SendingMail method  but can not figure out how to get it to email me instead of the person that registered. I have searched around this site and find many topics on the SendingMail method but none seem to properly address my issue. Can anyone help me out?


Categories: 
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