F# the namespace or module 'XXXX' is not defined - asp.net

I'm trying to create a basic ASP.net f# application and when I'm trying to reference the Youtube .net API I'm getting a "The namespace or module 'Google' is not defined" in my code behind file.
I've used the default ASP web forms template in Visual Studio, removed all of the contents, then loaded in the examples from Expert F#, Chapter 14. The default examples run fine, the problem only occurs when loading the Google API. The API works fine when I load it through an f# console application.
The first few lines behind file looks like:
#light
namespace MyASPApp
open System
open System.Web
open System.Web.UI
open System.Web.UI.WebControls
open Google.YouTube
Can anyone think of a resolution to the problem, or anything I could check to understand why its not picking up the Google API?

The Google assembly may require that the application not use the Client Profile, which is the default in VS 2010. Try editing the project settings and changing the Target Framework property.

Did you check which version of .NET Framework that google assembly is built for? If it .NET 3.5 or .NET 4.0? If that is not set properly too this will occur.
-Fahad

Related

Missing Linq to SQL namespace in Visual Studio 2012 Web Site Project

The hosting provider for one of the web sites I manage has forced us to only be able to modify the site as a web project instead of as a web application. When it was initially a web application it was working fine, but after converting to a web site project I had many issues involving missing namespaces and references and was able to resolve them by placing all of my libraries inside of the top-level App_Code folder of the web site. I have one last issue with my linq-to-sql class - in Visual Studio the class is recognized now that it's in the top level App_Code folder, but when I call a page which references it I get the following error:
The type or namespace name 'LIFH_IntakesDataContext' could not be found (are you missing a using directive or an assembly reference?)
Initially there was no namespace whatsoever, but in my attempts to fix this I addded a "LIHS" namespace and placed the Data Context within that:
Here are the references for the site:
And here is the Build configuration:
And, here is my directory structure (Linq-to-SQL class is referenced in the circled "reports.aspx" page):
Code in reports.aspx:
Both the master page and the reports page are both in the LIHS namespace.
I am developing on Visual Studio 2012 and the application pool is set to .NET 2.0. The hosting provider does not allow anything above 2.0.
I have researched and found many references to my issue but most of them solve the problem by converting to a web application, which I cannot do, or by changing the target framework or by using a namespace, which I have done, but to no avail. I would appreciate any insight on this.
Pay Attention: Linq is only available in .Net 3.5 and later
If you are using .net 2.0 it wont work.
You can see it in your screenshot.
Hope it helps.
Mike

Is it necessary to manually add <AutoGenerateBindingRedirect> metadata to the Core project file to correctly reference assemblies?

I'm using Visual Studio 2013 and MvvmCross to create an Android application using Portable Class Libraries.
I notice in my first view model, CatalogViewModel, some code is highlighted as not referencing the correct assemblies or unable to be resolved (the code builds fine even with these issues).
Examining the .NET Portable Subset assembly in the Object Browser shows various System assemblies included (2.0.5.0 v2.0.50727 & v4.0.30319, 4.0.0.0, 5.0.5.0). Automatic binding redirection for assemblies in .NET Framework 4.5.1 can be enabled or disabled by adding this line to the .csproj file.
<AutoGenerateBindingRedirect>true</AutoGenerateBindingRedirect>
or
<AutoGenerateBindingRedirect>false</AutoGenerateBindingRedirect>
This seems to solve the referencing and redirection issues in the IDE. I haven't found any information about this manual modification to the Core project file in any of the MvvmCross info online I reviewed so I wanted to post a question here to see if anyone had some information or best practices.
No, you shouldn't need AutoGenerateBindingRedirect. This feature is intended to generate binding redirects for non-platform assemblies, such as NuGet packages. Platform assemblies should be unified automatically by Visual Studio / MSBuild.
Which seems to work, since you pointed out:
the code builds fine even with these issues
So this looks like a bug in ReSharper. The fact that adding AutoGenerateBindingRedirect fixes your ReSharper issues might be a side effect of something else.

What is my problem with ASP.NET pubslishing?

I am done testing my site and I want to upload it to a site like this
http://www.university.edu/mydepartment/myname
the admin told me the server runs on .NET 3.5. So i used Linq ...
now i tried to upload the site by two ways:
when i just copy everything (with modification of web.config database settings) i get an error:
CS0246: The type or namespace name
'DataClassesDataContext' could not be
found (are you missing a using
directive or an assembly reference?)
Version Information: Microsoft .NET
Framework Version:2.0.50727.3082;
ASP.NET Version:2.0.50727.3082
Note here it says version 2.0
did he just lie to me? or its my configuration mistake?
anyway, i added the reference, nothing changes.
I tried also publishing (Build, publish) with option to keep the pre-comiled site updatable, and I get one line saying:
this is a makefile and should be
deleted!
what is going on?
It looks like it can't find your DBML file, or your DBML file isn't called "DataClasses.dbml". Also, the .NET Framework Version is not lying. It is reporting the CLR version, which is still 2.0 for the 3.5 .NET Framework.

ASP.NET 2.0 application won't compile when adding a Microsoft Report to the solution

I have a ASP.NET 2.0 web application. To that solution I add a Report (Reporting Services).
I make no further changes to that report. When I try build the application the build fails with the following error originating from that report file:
A namespace does not directly contain members such as fields or
methods
The problem was Visual Studio. I've restarted the IDE and could compile the application without problems.

CodeFile vs CodeBehind

What is the difference between CodeFile="file.ascx.cs" and CodeBehind="file.ascx.cs" in the declaration of a ASP.NET user control?
Is one newer or recommended? Or do they have specific usage?
CodeBehind: Needs to be compiled (ASP.NET 1.1 model). The compiled binary is placed in the bin folder of the website. You need to do a compile in Visual Studio before you deploy. It's a good model when you don't want the source code to be viewable as plain text. For example when delivering to a customer to whom you don't have an obligation to provide code.
CodeFile: You provide the source file with the solution for deployment. ASP.NET 2.0 runtime compiles the code when needed. The compiled files are at Microsoft.NET[.NET version]\Temporary ASP.NET Files.
I'm working with an Application Project in Visual Studio Express 2012 For Web and using .NET 4.0. In the code behind files for my login and change password pages I found a situation where I needed both CodeBehind and CodeFile in the declaration.
If I don't add a code file reference like
CodeFile=login.aspx.cs
The web page doesn't parse and the browser displays a parser error. It doesn't matter whether I compile the project or not.
If I don't add a code behind reference like
CodeBehind=login.aspx.cs
References to Security classes like MembershipUser fail both at compile time and when attempting to use intellisense with an error like "The type or namespace MembershipUser cannot be found". I have added a reference to System.Web.ApplicationServices as required by the .Net 4.0 framework.
I should add that these troublesome files are running in an application within the website created using the IIS Application tool. When I open the website from Visual Studio I have no difficulty with parser errors or reference errors. This confusion only occurs when I open the application as a project in Visual Studio.
Codebehind file need to compile before run but in src we dont need to compile and then run.. just save the file.

Resources