I am trying to add SQL lite to a phone project. I am following the Peter Huene project and SQLite-net-wp8 - https://github.com/peterhuene/sqlite-net - But I keep getting the error SQLiteConnection not defined. (I did set references and Nuget packages.)
The part I skipped is the conditional compilation symbols change he mentions (add USE_WP8_NATIVE_SQLITE) - My property page does not show a build tab - I have looked all over for the place to make that change but can't find it. Any thoughts?
Here is what my structure looks like (basically):
-Windows8PhoneMainProject
-SQLiteProject
SQLite.cs and SQLiteAsync.cs files are under SQLiteproject (not sure where I should place them - it seems to make no difference)
What am I missing? I find not Build tab or Conditional Compilation Symbols setting.
I found the answer - thought I would share it. It was because I was using VB instead of C# - had to add a C# project. (see below)
To use SQLite for wp8 with VB you are going to need 3 projects. The c++ SQLiteProject, the windows phone 8 VB project, and a C# windows phone 8 class library. Add the SQLite.cs and SqliteAsync.cs to the c# class library and add a reference to the c# dll in the VB project
Answered by MS forum:
http://social.msdn.microsoft.com/Forums/wpapps/en-US/46ff757a-3951-45fc-a267-2a221cd45006/sqlite-and-vb-cannot-see-sqliteconnection?forum=wptools
Related
I created a new .NET 6 Blazor Server-side project and made a couple of changes. I have a couple of files using CSS isolation (like Contact.razor + Contact.razor.css).. In the _Layout.cshtml page the template added the following:
<link href="CustomerPortal.styles.css" rel="stylesheet" />
Where CustomerPortal is my Project Name. I can see the file is generated correctly under "CustomerPortal\CustomerPortal\obj\Debug\net6.0\scopedcss\projectbundle\CustomerPortal.bundle.scp.css" and "C:\Data\Git\WebApps\CustomerPortal\CustomerPortal\obj\Debug\net6.0\scopedcss\bundle\CustomerPortal.styles.css"
BUT when I run the project, both with Kernel or IIS Express, I get a 404 not found for the CSS, if I try to manually navigate to the CSS I also can't find it. Any ideas? My csproj doesn't have any flags that would affect it.
Edit:
There is a new extension as part of the minimal setup in .NET 7, and backported to newer versions of .NET 6 as well.
Both in .NET 7 and .NET 6 you can now do:
builder.WebHost.UseStaticWebAssets();
Old answer:
You've got a couple options here to resolve this depending on the approach you want to take. I think we've figured out why it's happening, but UseStaticWebAssets() seems to not be supported for the new minimal startup code. So, here's your options I can think of off the top of my head.
Migrate your code back to the "old" way of doing application startup. This is still a supported and completely valid approach as there's edge cases that aren't supported (like this one).
Pass a new WebApplicationOptions to the CreateBuilder() method and, depending on environment, look for the static files in a separate (and correct) location. See some examples here.
With the existing builder, check the environment and use the StaticWebAssetsLoader to load static web assets.
A complete example of #3
if (builder.Environment.IsEnvironment("Local"))
{
StaticWebAssetsLoader.UseStaticWebAssets(builder.Environment, builder.Configuration);
}
That being said - I'd imagine they'll plug this hole eventually and provide parity for UseStaticWebAssets(). You can see the progress of this effort in this open GitHub issue.
For anyone else...
I had the exact same issue with a .net 6 blazor server app. For me it came down to the fact that I had changed the project name but the reference to {project}.styles.css in _Layout.cshtml was still pointing to the old project name.
Simply updating {project} here to the correct project name fixed my issue.
When I encountered this error, it was because I'd named my MVC project with a hyphen: htmx-spike.
When I generated the project from a template (dotnet new mvc -o htmx-spike), the tooling renamed the namespace to htmx_spike—with an underscore instead of a hyphen, because hyphens aren't allowed in C# identifiers—and used that modified name as the CSS filename in _Layout.cshtml.
However, it turns out that in this case the CSS location actually still corresponds with the project name, with the hyphen. So the auto-generated code is incorrect, and was causing the 404 to be returned:
Once I renamed the file in the link element to the correct name with the hyphen, everything was fine.
I had the same issue with a component I imported from another project. I solved it by closing all instances of Visual Studio, deleting the hidden folder [.vs] from the project folder, and then restarting the project in Visual Studio. On restart, Visual Studio recreated that folder and imported CSS file(s) were included.
Apologies if this sounds like a silly question. I'm not very experienced with how things are linked/bundled/assembled under the hood.
Before I begin, I'd like to say that I've tried reading documentation (such as https://learn.microsoft.com/en-us/xamarin/cross-platform/app-fundamentals/code-sharing) to find the answer, but was unable to.
If I have a Xamarin.Forms solution and I reference a .Net Standard project:
Question 1: Does all the code from this project get compiled and included into the app such that it may be disassembled later, or is it only code from classes that I actually make use of that gets included?
Bit more elaboration:
For example, I may have a School class that expects an IStudent (inject via DI), and a Student class that implements IStudent. Both of these exist in the .Net Standard project that I reference in the Xamarin.Forms project. However, if I only actually make use of the Student class (by registering it with type IStudent in my IoC container), will the code from School get included in the built app as well?
Question 2: If all the code from the project does get included, is there a way to forcefully specify which classes to include/exclude by way of some configuration setting, attributes, 3rd-party library, or something else?
As far as i know everything in the NETStandard project get compiled and shipped with the app.
If you want to remove unused code from compiled assemblies you have to use the linker.
To link everything, you have to select "Sdk and User Assemblies".
The linker tries to dont strip away mthods and fields you are using, but often is too aggressive (for example, methods referenced only by reflection will be stripped).
Luckily there are few methods where you can fine-tune the linker behaviour and make it work. Some link to elaborate on:
Linker in iOS and Android
https://learn.microsoft.com/en-us/xamarin/ios/deploy-test/linker
https://learn.microsoft.com/en-us/xamarin/android/deploy-test/linker
Official doc about the linker config:
https://learn.microsoft.com/en-us/xamarin/cross-platform/deploy-test/linker
Useful blogposts:
https://xamarinhelp.com/xamarin-linker/
https://medium.com/#harrycblum/reduce-your-xamarin-app-size-with-linking-26247edc87f6
Ok, I am in the process of breaking apart of intranet application (VS 2010 Web Site, ASP.NET Web Forms with VB code behind). During this process i'm trying to convert some of our our app_code files in to WCF rest service in a new project. However, when I copy or "add existing" vb files into the new "services" project. I get tons of errors including...
error BC30002: Type 'XXX' is not defined
warning BC40056: Namespace
or type specified in the Imports 'System.ServiceModel' doesn't
contain any public member or cannot be found. Make sure the
namespace or the type is defined and contains at least one public
member. Make sure the imported element name doesn't use any aliases.
From what i've read it may (or may not) have something to do with Assemblies and references that I just have very little knowledge on. I have added the namespaces from the current web.config to new project's web.config, and the files are identical. So there is something in the background that needs to be added to the new project I just don't know what its.
PLEASE HELP!!
THANKS
JOSH
UPDATE 1
So one of the errors i'm getting = "error BC30002: Type 'MailMessage' is not defined." Which is a namespace that is added to the web.config, which apparently isn't being picked up??? IDEAS?
I've come across a similar issue - not sure what the reasoning behind it is, but I got around it by creating a new .vb class with the same name as the one you want to copy, then copy and paste all the text from the old one to the new one. Save it, then it seems to like it - it didn't like me copying and pasting the actual file, nor did it like me adding existing files.
Hope this helps :/
This issue seems to be tied to the the differences between Web Application Projects versus Web Site Projects. Eventually I had to add different namespaces on the new project level.
Here is more info about WAP vs WSP....
http://msdn.microsoft.com/en-us/library/dd547590(v=vs.110).aspx
I am developing WP8 app on VS 2012 Express. Installed SQLite for Windows Phone and Sqlite-net.
And imported SQLite for Windows Phone as references.
However when I was trying to build the project it says:
Error 1 The type or namespace name 'Community' could not be found (are you missing a using directive or an assembly reference?)
And
Error 4 The type or namespace name 'Sqlite3' could not be found (are you missing a using directive or an assembly reference?)
What did I miss?
I think you forgot to add USE_WP8_NATIVE_SQLITE to your conditional compilation symbol.
#if USE_CSHARP_SQLITE
using Sqlite3 = Community.CsharpSqlite.Sqlite3;
using Sqlite3DatabaseHandle = Community.CsharpSqlite.Sqlite3.sqlite3;
using Sqlite3Statement = Community.CsharpSqlite.Sqlite3.Vdbe;
#elif USE_WP8_NATIVE_SQLITE
using Sqlite3 = Sqlite.Sqlite3;
using Sqlite3DatabaseHandle = Sqlite.Database;
using Sqlite3Statement = Sqlite.Statement;
I tested it, seems to be a bit problem with Windows phone 8 and Sqlite.
First thing to solve your problem is, to add the "Community.Csharpsqlite.WP" reference to the app. To do this, open the Nuget package manager and type "csharpsqlite" and install the resultant nuget package in your app. This resolves both the above issues you mentioned in your question. but agian, raises another problem. There are some incompatible methods in between "Community.Csharpsqlite.WP" and SQLite.cs file from "sqlite-net". One solution for this is to manually modify the methods in SQLite.cs to resolve the incompatibilities.
Alternatively, if the above process doesn't work out for you, then use the process of WP7 sqlite as mentioned in the dotnetslackers link. Test this in a separate project and hopefully this should work.
I got it working on Windows Phone 8 without csharpsqlite.
Peterhuene created a wrapper for SQLite which you can get from GitHub. No csharpsqlite needed anymore. The readme section contains all information needed.
A detailed description of how to set it up can also be found here on CodeProject.
I'm assuming you followed the instruction in this post
In the post there is an instruction that you add a c++ project to your solution named Sqlite. You get it from github. Admittedly this is very well hidden within the post and is easy to miss.
After including the c++ project to your solution you should add a reference to it from your C# project.
Add reference -> solution -> choose the c++ "Sqlite" project As a reference
After that, and adding the build constant USE_WP8_NATIVE_SQLITE it should work.
In SQLite.cs, there are several places you will see such lines
#if USE_CSHARP_SQLITE
...
...
#elif USE_WP8_NATIVE_SQLITE
...
...
Just replace the codes inside #if USE_CSHARP_SQLITE with the codes inside #elif USE_WP8_NATIVE_SQLITE and you are good to go.
Or there is also a short method. Go to properties->build and after ; add "USE_WP8_NATIVE_SQLITE" and rebuild the solution. This worked for me
It's been a while since I've created a new ASP.NET web application. (I've been doing ASP.NET MVC for the last 9 months, and hadn't done an ASP.NET site for about a year before that.) Now I've created a new regular ASP.NET app and when I look at the Default.aspx file, Visual Studio is only displaying the HTML tab in the Toolbox. I don't have the WebControls or the data access controls. (I don't even remember what other tabs I should be seeing.)
When I try to add a web control manually like this,
<asp:Label id="LabelTest" runat="server"></asp:Label>
I get a green squiggly and the tool tip says Unrecognized namespace 'asp'.
What do I need to do to get the Web Controls in my toolbox and also get the namespace to be recognized?
I've got this line in my page load event:
LabelTest.Text = "testing"
My app compiles and runs as expected -- the label displays testing.
So, I could word around it, but this will just make designing the forms more difficult.
Update: I've tried all 3 of the suggestions posted as answers so far and nothing has helped. Now I'm seeing a different error in addition to what I was getting before. In the designer I now see this:
Error Creating Control - LabelTest
Could not load file or assembly 'Microsoft.Web.Authoring' or one of its dependencies. The system cannot find the file specified.
Have you tried repairing the Visual Studio installation?
Pops-in the disc and select "Repair"?
If that doesn't work, then I think you should just re-install Visual Studio... It seems like a plugins/add-on corrupted the toolbox
Have you tried
removing and then re-adding the assembly references and then
rebuilding the solution?
Have you tried the "Reset Toolbox" command?
reset toolbox http://chakrit.net/files/stackoverflow/so_reset_toolbox.png
...