DomainContext not being generated in RIA Service for Silverlight 4 - vb.net

I have added my domain service but when I build my web project the DomainContext never gets generated. I am new to RIA Services and trying to learn but I am really stuck.
Here is my Domain Service
Option Compare Binary
Option Infer On
Option Strict On
Option Explicit On
Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.ComponentModel.DataAnnotations
Imports System.Linq
Imports System.ServiceModel.DomainServices.Hosting
Imports System.ServiceModel.DomainServices.Server
Imports Wellness.BL
Imports System.Collections.ObjectModel
'TODO: Create methods containing your application logic.
<EnableClientAccess()> _
Public Class EventScheduleService
Inherits DomainService
Public Function GetEventSchedule(ByVal ScheduleYear As Integer) As IEnumerable(Of Models.EventSchedule)
Return DataServices.EventSchedulesDataService.GetEventSchedule(ScheduleYear)
End Function
End Class

Maybe Models.EventSchedule, the class that is the base for your IEnumerable, is in a library that you have referenced in the Web project but can not be referenced in the client as it is not a Silverlight library?
I think that would prevent the EventScheduleDataContext from being generated in the client.
A simple test would be to change base of the IEnumerable to a class that lives in the Web project.

I had this problem also. My problem was that Visual Studio was set to Release mode. Setting it to Debug mode solved it.

Related

VB.Net: LUIS Dialog context.Wait(MessageReceived) issue

As a challenge to myself, I've created a Visual Basic app that uses the Microsoft Bot Framework and LUIS API. To my own amusement, I've largely gotten it working .. almost.
After getting over some C# to VB hurdles, there's one I can't get over, which is stopping my app from keeping the conversation stack from functioning properly (it bails out after one interaction).
Specifically, I have the following code fragment inside of my dialog code:
Imports System
Imports System.Threading.Tasks
Imports Microsoft.Bot.Builder.Dialogs
Imports Microsoft.Bot.Builder.Luis
Imports Microsoft.Bot.Builder.Luis.Models
<LuisModel(“xxxxxxxxxxxxxxxxxxxxxxxxxx”, "xxxxxxxxxxxxxxxxxxxxxxxxxx")>
<Serializable>
Public Class MyLuisDialog
Inherits LuisDialog(Of Object)
<LuisIntent("None")>
Public Async Function NoneIntent(context As IDialogContext, result As LuisResult) As Task
Await context.PostAsync(“this is boring chat ..“)
context.Wait(MessageReceived)
End Function
but I cannot interpret the context.wait(MessageReceived) from C# into VB.
The compiler wants to do:
context.wait(MessageReceived(context,????????))
but I cannot figure out what to put in for ?????.
Irritatingly, the C# version just works in the form context.wait(MessageReceived).
Assistance as to what syntax/code should be used when using VB gratefully accepted :)
Try with context.Wait(AddressOf MessageReceived)

Microsoft.AspNet.Identity.Owin.OwinContextExtensions doesn't seem to work

I am creating a custom asp.net.identity provider in a separate assembly in order to use it from two different web api 2 projects.
I took the default vs2013 template for a web api project as a guide and so far I have implement the required classes.
In the separate assembly I am using a user manager class derived from Microsoft.AspNet.Identity.UserManager(Of T) class.
Public Class EzeUserManager
Inherits UserManager(Of EzeIdentityUser)
Now I want to implement the create shared function in order to use as a callback in the CreatePerOwinContext function. According to the template, I am declaring it like this:
Imports System.Threading.Tasks
Imports Microsoft.AspNet.Identity
Imports Microsoft.AspNet.Identity.Owin
Imports Microsoft.Owin
Public Class EzeUserManager
Inherits UserManager(Of EzeIdentityUser)
... Class Implementation ...
Public Shared Function Create(options As IdentityFactoryOptions(Of EzeUserManager), context As IOwinContext)
Dim Result As New EzeUserManager(New EzeIdentityUserStore(context.Get(Of EzeLDAPContext)()))
The problem is that
context.Get(Of EzeLDAPContext)()
fails because it requires a key.
From the template I can see that the get method which doesn't require a key is an extension defined in Microsoft.AspNet.Identity.Owin.OwinContextExtensions which I have already installed and referenced through nuget and imported it in the class.
But it doesn't work.
I found that the key is actually the type name of the class so probably I can overcome this problem, however I didn't try it yet because I really want to make the extensions to work.
The question is: Am I missing something here?
Notes: The project in question is a Class Library targeting .NET 4.5.1 with the following references:
Microsoft.AspNet.Identity.Core
Microsoft.AspNet.Identity.Owin
Microsoft.Owin
Microsoft.Owin.Security
Microsoft.Owin.Security.Cookies
Microsoft.Owin.Security.OAuth
Newtonsoft.Json
Owin
As I explained in the question, I was using the template generated by VS as a guide. During the implementation process of my project, I had update the nuget packages several times but only in my project not in the template project (same solution) since I was going to deleted it afterwards. This resulted the two projects to reference two different versions of the required assemblies.
I don't know how exactly and why this "multi" reference caused this problem but once I updated the template project's nuget packages the problem was resolved.
I hope this helps someone with a similar issue.

'IDTExtensibility2' is ambiguous in the namespace 'Extensibility'

I am trying to build a COM Add-In and I get the errors:
'IDTExtensibility2' is ambiguous in the namespace 'Extensibility'.
'ext_DisconnectMode' is ambiguous in the namespace 'Extensibility'.
'ext_ConnectMode' is ambiguous in the namespace 'Extensibility'.
My imports are as follows:
Imports Extensibility
Imports System.Runtime.InteropServices
Imports Microsoft.Office.Interop
Imports Microsoft.Office.Interop.Excel
Imports Microsoft.Office.Core
I used the shared add-in wizard in VS 2010 and I am using VB.NET.
The codes that have errors are anything that contains:
Extensibility.IDTExtensibility2
I couldn't find this anywhere and I figured the wizard would work without errors. Any thoughts? Thank you.
Check whether one of the Microsoft.* namespaces already imports the Extensibility namespace.
If not, there is possibly an upper-/lowercase ambiguity, try whether you can access the class in C# or through reflection.
If it still does not works, there probably goes something wrong during interop proxy generation but then it get's complicated, you have to use the tlbimp.exe tool and toy around with its options.

How can I create a DLL for extension methods in VB.net?

Ladies and gentlemen,
I am trying to create a DLL I can share between a few different projects that includes a variety of extension methods I've written to simplify my code. In understand such DLL's are feasable to share between C# and VB.net projects. I however have been unable thus far to create a DLL, or even to include the sub project and reference it that way and be able to access my extensions.
I am able to see the reference in the object browser, but import statements do not bring up my sub-project reference as an option. VB.net does not allow me to place the extensions within classes, and I can't seem to find any clues on the web that would explain this. Thanks in advance.
Example...
Imports System.Runtime.CompilerServices
Imports System.Text.RegularExpressions
Module Extensions
<System.Runtime.CompilerServices.Extension()>
Public Function ToEnum(Of T)(ByVal value As String) As T
Try
Return (CType([Enum].Parse(GetType(T), value.Replace(" ", ""), True), T))
Catch ex As Exception
Return (CType([Enum].Parse(GetType(T), 0, True), T))
End Try
End Function
End Module
You need to mark your Extensions module with the Public keyword. Also, make sure that your project properties in your consuming project lists your library project as a reference; simply appearing in the Object Browser doesn't mean you've set up the reference properly.
The following console application code is perhaps nonsensical, but leverages your exact code above with the exception that I made your module Public versus the default of Friend.
In my solution, ClassLibrary3 is the VB class library project and included as a reference in the console application project.
Imports ClassLibrary3.Extensions
Module Module1
Sub Main()
Dim f As String = "hello"
Console.WriteLine(f.ToEnum(Of System.ConsoleColor)())
End Sub
End Module

How to use reflection to unit-test an internal (Friend in VB) class within an assembly, when the InternalsVisibleToAttribute is not an option?

I have a solution with two projects within:
Company.Project.vbproj
Company.Project.Tests.vbproj
Within the Company.Project.vbproj assembly, I have a class FriendClass.vb which scope is Friend (internal in C#).
Now I wish to test this FriendClass.vb from within the Company.Project.Tests.vbproj assembly. I know about the InternalsVisibleToAttribute, but that is not an option in Visual Basic .NET 2.0, as it is only available with C#, in .NET 2.0 (see here).
I would like to create myself a proxy class using this internal FriendClass from within my testing assembly, so that I could instantiate it and do the testings accordingly.
Any idea or known practices to do so?
Thanks in advance! =)
The only workaround that I have found is one used back in .NET Framework 1.1.
As the InternalsVisibleToAttribute is not useable in .NET 2.0 Visual Basic, the only workaround that I have found is to include my tests within the same project as my library itself. Besides, some further work needs to be accomplished.
Create yourself a new compilation CONFIG called "Tests" (that is where you may select "Release"/"Debug");
Create a new folder named "Tests" within your project;
Add a new class, the one to test your Friend (internal in C#) members;
First line of code within this class should be: #if CONFIG = "Tests" then ... #end if;
Place your code between this compiler IF directive.
For example, if I have the following Friend class:
Friend Class MyFactory
Friend Property Property1 As Object
Get
Return _field1
End Get
Set (ByVal value As Object)
_field1 = value
End Set
End Property
Friend Sub SomeSub(ByVal param1 As Object)
' Processing here...
End Sub
End Class
Then, if you want to test this class in .NET 2.0 Visual Basic, you will need to create a test class within the same project where the MyFactory class sits. This class should look like so:
#If CONFIG = "Tests" Then
Imports NUnit.Framework
<TestFixture()> _
Public Class MyFactoryTests
<Test()> _
Public Sub SettingProperty1Test
' Doing test here...
End Sub
End Class
#End If
Since you have a compiler directive telling the compiler to compile and to include this class only when the "Tests" CONFIG is selected, you won't get this class on "Debug" or on "Release" mode. This class won't even be part of the library, this for not polluting your library unnecessarily, and this allows you to test your Friend class anyway.
That is the smartest way I have found to work around this issue in Visual Basic .NET 2.0.