I created a couple of extended methods in a VB.NET module. I put them inside a Class, built it and got the DLL.
From another program I made a reference to that DLL and imported it using Imports as well.
The extended methods appear in IntelliSense and it works but a warning appears in the Error console saying,
Could not resolve this reference. Could not locate the assembly “nK0deExtendedMethods”. Check to make sure the assembly exists on disk.
Does anyone know why this error occurs even though I have referenced the DLL??
This is the Class where I’ve put my module with the extended method.
Imports System.Runtime.CompilerServices
Imports System.Drawing
Namespace nK0deExtendedMethods
Public Module ExtMethods
<Extension()>
Public Function Merge(ByVal img1 As Image, ByVal img2 As Image) As Image
Dim bmp As New Bitmap(Math.Max(img1.Width, img2.Width), img1.Height + img2.Height)
Dim g As Graphics = Graphics.FromImage(bmp)
g.DrawImage(img1, 0, 0, img1.Width, img1.Height)
g.DrawImage(img2, 0, img1.Height, img2.Width, img2.Width)
g.Dispose()
Return bmp
End Function
'Public Class NewImageMethods
'End Class
End Namespace
And I’m having another doubt. In the Imports statement, I have to mention the DLL’s name along with the Namespace name. Like this,
Imports ExtendedMethods.nK0deExtendedMethods
Normally you only have to import the Namespace’s name, right? why that is happening?
Thanks a lot everyone.
I just created a new
Class, removed theNamespaceand build it. That worked fine.