.net - Extension Methods In Referenced Assemblies?

Sep 16, 2010

If I try to call my extension method which is defined like this:

Module LinqExtensions
<System.Runtime.CompilerServices.Extension()> _
Public Function ToSortableBindingList(Of TSource)(ByVal source As IEnumerable(Of TSource))

[code].....

View 1 Replies


ADVERTISEMENT

Dynamically Referenced Assemblies And VBCodeProvider?

Mar 17, 2010

We have a large application that implements "scripting" (i.e, dynamically compiled user code that can include user-defined .dll references).

View 5 Replies

Dynamically Referenced Assemblies And VBCodeProvider .net 2.0, Visual Studio 2008?

Apr 1, 2010

I just realized I used my non-partner account the first time, and I want to make sure I receive priority support. In addition, I found out more about my problem and made a much clearer example.Basically I'm having problems getting a dynamically compiled vb.net "script" to find external references (even though they are being added by fully qualified path). I also tried adding /libpath to my compiler options, and still it cannot find the assemblies.[URL]..

And here is a reference to my original post (with not-so-easy to understand code snippets):[URL]..

View 2 Replies

Access The Events And The Methods Of These Assemblies Directly Without Always Using Reflection?

Mar 6, 2012

If I have an application that load some assembly at runtime. Is it possible to access the events and the methods of these assemblies direcly, without always using Reflection

View 15 Replies

Can't Access Class Library Methods / Properties When Referenced As A DLL

Oct 15, 2009

I've created a class library and built a dll (release build). I've then referenced the DLL in another project (I've tried several). I can see the namespace and classes in Object Browser and I can declare instances of the classes but I cannot use or see any of the methods or properties! there is no IntelliSense whatsoever and calling the methods manualy results in a 'Declaration expected' error.

Within the class library solution I have a unit test project referencing the class library project which works all works fine (and all the tests pass).

Can anyone provide any pointers to what might be going wrong here? I've built plenty of dlls in the past and have had no trouble referencing them at all.[code]...

View 3 Replies

.net - Extension Methods In T4?

Mar 28, 2012

I'm trying to use PGK.Extensions in a T4 template in VS2008 for VB.NET and I get:

RemoveAllSpecialCharacters is not a member of string..

My T4 headers:

<#@ template language="VB" hostspecific="false" debug="true" inherits="Microsoft.VisualStudio.TextTemplating.VSHost.ModelingTextTransformation" #>
<#@ output extension="vb" #>
<#@ assembly name="PGK.Extensions.dll" #> // the dll is found
<#@ import namespace="StringExtensions" #> //Try with and without namespace

[Code]...

View 1 Replies

Why Use Extension Methods

Jan 7, 2010

I would like to know your opinion on extension methods. Sure, it is a nice feature and makes you feel powerful. It's great to see your own method pop up when typing in a object. But it doesn't really add something new... You can get the job done with normal methods as well. I think extension methods do not belong in object oriented programming. It makes your code easier to read but harder to understand for someone else.

View 2 Replies

.net - Extension Methods Error ?

Mar 7, 2011

CODE:

View 2 Replies

Asp.net Mvc - Combining Extension Methods?

Sep 5, 2009

I'm trying to write 2 extension methods to handle Enum types.One to use the description attribute to give some better explanation to the enum options and a second method to list the enum options and their description to use in a selectlist or some kind of collection.You can read my code up to now here:

<Extension()> _
Public Function ToDescriptionString(ByVal en As System.Enum) As String
Dim type As Type = en.GetType
Dim entries() As String = en.ToString().Split(","c)

[code]....

So my problem is both extension methods don't work that well together. The methods that converts the enum options to an ienumerable can't use the extension method to get the description.

View 1 Replies

Extension Methods For Object

Nov 9, 2011

I wonder why it's impossible to create and extension method for Object? I use Excel PIA. The property Cells of Worksheet returns Object (if using with indexes). For example, Worksheet.Cells(1, 1) returns Object type. I know it's a Range object, and I want to cast it to Range. It would be convenient to write following:[code]

View 5 Replies

How Do Extension Methods Really Work

Jan 25, 2010

I know what extension methods are, how to create and use them, but I wanted to know more about how they actually work. How do they "attach" themselves to the type of object that you are extending? Or is there even an attachment being made. I know want to know more about the inner workings, etc.. I looked around and read several different blog posts about extensions and not one of them discusses how they actually work.

View 6 Replies

.net - Syntax And String Extension Methods

Aug 30, 2011

Code in VB.NET

[Code]...

works very well. So seems some consistency miss of the string constant behavior.

2) Have a look on the COMMENTS (in the attached picture). The words "custom", "string" and "error" are highlighted, however they are in the comments, so should be green, not blue.

Why this? What workaround? EDIT: Declared as "bug" in Microsoft Connect (even if is not more that a syntactic "miss")... EDIT 2: As remarked Hans Passant, standard string methods, like "cucu".Trim() does not work either.

View 2 Replies

.net - Using Extension Methods From Within An Object's Constructor?

Feb 8, 2010

Consider the following:

Public Module Extensions
<Extension()> _
Public Sub Initialize(ByRef Target as SomeClass, ByVal SomeParam as Something )

[code].....

Why is Case 1 failing to initialize the object as expected?

View 1 Replies

How To Know If Class Has Been Extended With Extension Methods

May 30, 2012

In VB.NET or C#, is there a way to determine if a class has been extended with extension methods?

View 3 Replies

Way To Add An Overload To A Method That Already Has One Or More Extension Methods?

Jan 8, 2010

Is there anyway to add an overload "extension method" to a method that already has one or more extension methods?For example theString.Contains method has two extension methods totalling 3 separate versions.Is there anyway to add an extra extension method also called "Contains" ?By the way I have tried it but the IDE does not seem to recognise additional EXTENSION methods where a method already hasone or more extension methods.Is there anyway around this restriction?In other words I would like to be able to change the Extension method below from"Contain" to "Contains" but it seems it is not recognised.

Option Strict On
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles

[code].....

View 4 Replies

.net - Extension Methods From C# Dll Doesn't Work As Extensions?

Sep 17, 2010

I made a library in C# and I've been told by people that one of mine methods don't work in VB.NET as extension [UR]

this is the method:

public static PropertyDescriptorCollection GetProps(this object o)
{
return GetProps(o.GetType());
}

View 1 Replies

.net - Extension Methods In VB 2008 Assembly Cannot Be Used In A C# Project?

Jun 1, 2011

I wrote some string extension methods in a VB assembly and am unit testing them from a C# project. However, C# acts like it cannot see the the extension methods, when other VB projects reference the VB assembly they have no problem. Both the VB assemebly and the C# test project are targeting .Net 3.5. Is there a way around this?

[Code]...

View 1 Replies

Extension Select Methods For Entity Framework?

Dec 14, 2011

I have many similar calls to database and they work fine

Using ta As New QT_SSTEntities
Return ta.Product.
Select(Function(c) New RadComboBoxData() With {.Text = c.FieldName1, .Value = c.FieldName1}).

[Code].....

View 1 Replies

.net - Check That Extension Methods On An Array Got A Specific Size?

May 30, 2012

I'm using extension methods based on an array and I would like to know if there is an easy way to check that array got a specify size instead of me doing a copy paste of

if array.count != 1000
throw new exception "size of the array does not match"
in about ~50 extensions

this a small sample of extensions that I use, I got WAY more

<Extension()>
Public Function IsWhite(ByVal board() As bitPiece, ByVal pos As Integer) As Boolean
Return (board(pos) And bitPiece.White) = bitPiece.White
End Function

[code]....

View 3 Replies

Doesn't C# Extension Methods Allow Passing Parameters By Reference?

Aug 11, 2009

Is it really impossible to create an extension method in C# where the instance is passed as a reference?

Heres a sample VB.NET console app:
Imports System.Runtime.CompilerServices
Module Module1

[code].....

View 3 Replies

LINQ To XML Result Object Not Showing Extension Methods

Jan 9, 2012

I have the code as below:
Dim xdTest As XDocument = XDocument.Load(GetXMLPath())
Dim objResult = From xe In xdTest.Elements("Some Element") _
Where xe.Element("strName").Value = strInput _
Select xe.Element("intValue").Value
objResult.
I cannot access any extension methods for objResult, like .ToList() or .First(). The file imports System.Linq and the project is targeted to .NET 3.5. How do I get the extension methods back?

View 1 Replies

MVC2 Extension Methods Throwing Errors In Views?

Nov 21, 2011

I have a project written in MVC2 and VB.NET. I use a lot of htmlhelper extension methods,and I have them all in a public module. They work just fine, and I can compile and run my project. I reference the namespace they are in with this:<%@ Import Namespace="MyProject.WebUI.Extensions" %>So, again, they work great, my project runs and compiles without a hitch.The problem is that each one of these extension methods is shown as an error:

Error 33 'TabbedMenu' is not a member of 'System.Web.Mvc.HtmlHelper(Of Object)'. C:ProjectsMyProjectMyProject.WebUIViewsSharedSite.Master 23 21 MyProject.WebUI

[code]....

View 2 Replies

Silverlight - Useful Extension Methods In System.data.* Namespace?

Nov 21, 2011

I have a number of very useful extension methods that I'd like to use in my Silverlight project.I've pasted the Module here [URL]The problem I'm having is that visual studio complains that the dlls my module have been written against have not been built against the Silverlight runtime.Is there an easy way to get these extension methods working in Silverlight?I'm thinking my main hurdle is getting IObjectSet and ObjectContext to run against the Silverlight run-time - perhaps there's another way to expose these methods that I'm not aware of.

View 1 Replies

Mvc - Repository Pattern Implements Methods By Adding Add1 But Should Use Methods Of The Baseclass?

Aug 29, 2011

This is the original code in c#

public class CategoryRepository: RepositoryBase<Category>, ICategoryRepository
{
public CategoryRepository(IDatabaseFactory databaseFactory)
: base(databaseFactory)

[Code]...

Does anyone has an idea what i should change to let it work and let my UserRepository use the methods in RepositoryBase while implementing the IUserRepository?

View 1 Replies

Use An Extension Method Instead Of Just Creating Non-extension Sub Or Function?

Dec 3, 2009

Why would I use an extension method instead of just creating non-extension sub or function?

For ex, I could have an extension function called IsNullOrEmptyOrAllSpaces on String, which does a check as its name implies. Or I can write a stand alone function that does the same thing. Other than having the extension show up in Intellisense, is there any advantage? Is a call to the extension quicker/more efficient than a call to a regular function?

View 8 Replies

Cant See Available Methods List When Write Object.METHODS?

Jun 24, 2011

I am working with a vb program, but there is something strange on one of my .vb code pagewhen i put the "dot" afther the object name its dont show the methods availables for this objectbut on other vb code pages i can see it. but in this one no.for exmaplethis is a piece of code: Dim sb As New StringBuilder()

View 3 Replies

Making Class Methods Instead Of Instance Methods In .NET?

Mar 29, 2010

I am not sure how clear my question is by the title, but I am trying to make Class methods instead of Instance methods in Visual Basic that way I don't have to waste memory and code creating temporary objects to execute methods that don't need instance variables.

I am not sure if you can do that in VB but I know you can in Objective-C by using either a "+" or "-" sign in front of the method declaration. And in C++ (at least I think, I can't remember) you put the static keyword or const keyword in front of the function.How would I do this in VB if it is possible? Or should I just make a separate set of functions that are not members of a class?

View 2 Replies

VB Extension Property Instead Of Extension Method

Mar 16, 2012

I saw this post and I want to know if this is possible in VB. So like extension method, do extension properties exists in VB.Net? Here I've read they do, but cannot find any examples.

View 3 Replies

VS 2008 Hide Extension When It's Not Used As An Extension?

Dec 9, 2011

If i have an extension ... say...

vb
<System.Runtime.CompilerServices.Extension()> _
Public Sub Invert(ByVal b As Bitmap)

is there any way of hiding this from inteli-sense if it is not used as an extension?so that pressing ctl+space only triggers it if you go "bitmap.Inve.." rather than prompting on "Inve..."?

View 2 Replies

How To Assemble Assemblies

Jun 13, 2011

In my .aspx file I have:

<%@ assembly src="extensions.vb" %>
<%@ assembly src="debug.vb" %>

[code].....

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved