DocumentClient.CreateDatabaseQuery - No definition exists - azure-cosmosdb

I'm trying to follow the azure DocumentDb quick start project. The app I will be developing will be in WPF rather than the console, so to ramp up on documentdb I created a new wpf project (.Net 4.5.1) but I get the following error:
'Microsoft.Azure.Documents.Client.DocumentClient' does not contain a definition for 'CreateDatabaseQuery' and no extension method 'CreateDatabaseQuery' accepting a first argument of type 'Microsoft.Azure.Documents.Client.DocumentClient' could be found (are you missing a using directive or an assembly reference?)
I used the following command to install the azure documentdb client:
Install-Package Microsoft.Azure.Documents.Client -Pre
This is the code that is giving me the issue (lifted straight from the quick start tutorial):
DocumentClient client = new DocumentClient(new Uri("endpoint"), "authKey");
var db = client.CreateDatabaseQuery()
.Where(d => d.Id == databaseId)
.AsEnumerable()
.FirstOrDefault();
This is the contents of my Nuget Packages.config file
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Azure.Documents.Client" version="0.9.1-preview" targetFramework="net451" />
<package id="Newtonsoft.Json" version="4.5.11" targetFramework="net451" />
</packages>
Anybody any ideas what I'm missing? I'm using Visual Studio 2013 Premium Update 4

I believe you are missing the using directive for the DocumentDB Linq provider (Microsoft.Azure.Documents.Linq). Please make sure you have the following directives to the top of your .cs file:
using Microsoft.Azure.Documents;
using Microsoft.Azure.Documents.Client;
using Microsoft.Azure.Documents.Linq;

Related

What Dotnet native directives to use for AsyncAwaitBestPractices.MVVM?

I'm using AsyncAwaitBestPractices.MVVM's IAsyncCommand and AsyncCommand in my Xamarin.Forms app. The UWP version of the app is compiled with .NET Native tool chain. When I do SomeAsyncCommand.RaiseCanExecuteChanged(), I get an exception:
System.Reflection.MissingMetadataException: 'This operation cannot be carried out because metadata for the following object was removed for performance reasons:\n\n EETypeRva:0x000976A0\n\nNo further information is available. Rebuild in debug mode for better information.\n\n'
Note that this was a debug build. When I added a local copy of the library, I was able to find the line that triggers the exception:
static bool IsLightweightMethod(this MethodBase method)
{
var typeInfoRTDynamicMethod = typeof(DynamicMethod).GetTypeInfo().GetDeclaredNestedType("RTDynamicMethod");
return ...
}
The exception is triggered by GetDeclaredNestedType("RTDynamicMethod"). So the binaries do include the metadata of DynamicMethod, but not that of it's child type RTDynamicMethod. They have been removed because of .NET Native tool chain.
Now, I read that you can whitelist classes / namespaces / assemblies in project properties -> Default.rd.xml. But I can't seem to get the right element to whitelist the nested class. Here's what I tried:
<Assembly Name="System.Private.CoreLib" Dynamic="Required All" />
<Namespace Name="System.Reflection.Emit" Dynamic="Required All" />
<Type Name="System.Reflection.Emit.DynamicMethod">
<Type Name="RTDynamicMethod" Dynamic="Required All"/>
</Type>
Here System.Private.CoreLib is the assembly of DynamicMethod, System.Reflection.Emit is the namespace of DynamicMethod and RTDynamicMethod. As far as I understand, either of the three should work, yet none of them do. Edit: the type one gives me a warning: Default.rd.xml(35): warning : ILTransform : warning ILT0027: Type 'System.Reflection.Emit.DynamicMethod' could not be found.
I also tried variations using Type Name="System.Reflection.Emit.DynamicMethod+RTDynamicMethod", using <Library>, with or without namespaces in type, etc.
At first, you can try to use the following code in the Default.rd.xml:
<Type Name="System.Reflection.Emit.DynamicMethod" Dynamic="Required All">
<Type Name="System.Reflection.Emit.RTDynamicMethod" Dynamic="Required All">
For more information, you can check the similar case and the issue on the github.
In addition, why did you add the tag .net 6.0? I have checked the package named System.Reflection.Emit, the last update time is 12/4/2019 and it does't support the .net 6.0.

Extension method IsNullOrWhiteSpace with the same namespace is placed in two assemblies

I have ASP.Net MVC project. The project contains WebGrease, packages.config:
<package id="WebGrease" version="1.5.2" targetFramework="net462" />
Recently because of (https://www.nuget.org/packages/BundleTransformer.MicrosoftAjax/) I added AjaxMin into my packages.config:
<package id="AjaxMin" version="5.14.5506.26202" targetFramework="net461" />
In my code, I am using IsNullOrWhiteSpace() extension method. The method actually exists in these two libraries:
Visual Studio cannot decided which one has to be used.
I cannot remove the reference to WebGrease, because if I do so, I have the following exception:
How can I solve the conflict?
Thank you
You can use string.IsNullOrWhitespace() directly.

Jboss 7 and datasources

I successfully configured Jboss 7 to work with Oracle 11g by installing the jdbc drivers as a module and adding the datasource definition in the standalone.xml.
However, now I want to move the datasource definition to it's own file which I dropped into the deployments directory.
That resulted in the following failure:
javax.naming.NameNotFoundException: jdbc/MyDatasource -- service jboss.naming.context.java.jboss.jdbc.MyDatasource
Is that not possible anymore with jboss 7?(I believe it used to be the case with jboss 5) Here is how the ds file looks:
<?xml version="1.0" encoding="UTF-8"?>
<datasources xmlns="http://www.jboss.org/ironjacamar/schema">
<datasource jndi-name="java:jboss/jdbc/MyDatasource" pool-name="OracleDS" enabled="true" jta="true" use-java-context="true" use-ccm="true">
<connection-url>jdbc:oracle:thin:#oracle.host:1521:mydb</connection-url>
<driver>
oracle
</driver>
<pool>
<min-pool-size>10</min-pool-size>
<max-pool-size>100</max-pool-size>
<prefill>false</prefill>
<use-strict-min>false</use-strict-min>
<flush-strategy>FailingConnectionOnly</flush-strategy>
</pool>
<security>
<user-name>user</user-name>
<password>pass</password>
</security>
<validation>
<validate-on-match>false</validate-on-match>
<background-validation>false</background-validation>
<use-fast-fail>false</use-fast-fail>
</validation>
</datasource>
<drivers>
<driver name="oracle" module="com.oracle.jdbc"/>
</drivers>
</datasources>
I do not know how you are doing the jndi look up,but from the error message it looks you are using the normal (old way) of java:jdbc/DatasourceName instead of the new way java:jboss/datasources/DatasourceName.
I tried xxx-ds.xml for data source configuration.
I got a WARN
12:22:12,988 WARN [org.jboss.as.connector.deployer.dsdeployer]
(MSC service thread 1-2) JBAS010411: <drivers/> in standalone -ds.xml
deployments aren't supported: Ignoring xxx-ds.xml
So from the message, I confirmed that JBoss7 doesn't support a separate ds file in stadalone mode.

How do I connect to SQLite with Simple.Data.SQLite

I wrote this code in Webmatrix 2.0 beta:
string Dbfile=HttpContext.Current.Server.MapPath("data/db.db3");
var Db = Simple.Data.Database.OpenFile(Dbfile);
Simple.Data.SimpleDataException: No ADO Provider found.
why??
I'm sure that I have included the reference:
packages.config
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Simple.Data.Ado" version="0.16.1.0" />
<package id="Simple.Data.Core" version="0.16.1.0" />
<package id="Simple.Data.Sqlite" version="0.16.0.0" />
<package id="System.Data.SQLite" version="1.0.80.0" />
</packages>
In my test application conn is the physical path including the the db filename and calling
cn = Database.OpenConnection(conn);
works for me. When I used OpenFile I also received the No ADO Provider error.
I am using (from NuGet):
Simple.Data.Core 0.16.1.0
Simple.Data.Ado 0.16.1.0
System.Data.SQLite 1.0.80.0
Simple.Data.Sqlite 0.16.0.0
System.Data.SQLite 1.0.80.0
Getting the dlls required for the System.Data.SQlite can be hassle. If you want to do it quickly then download the Nuget extension for VS 2010. Then you can get the dlls from the extensions console.
Make sure you read the extension installations instructions.

Change webserver used by Flex in FlexBuilder to .NET Framework 3.5

I just had to reformat and reinstall Flex and reconstruct a project.
The problem is i am using ASP.NET as my server side technology and using LINQ in my files. The version of WebDev.Webserver.exe that FlexBuilder starts up is the wrong version so I get this error :
Compiler Error Message: CS0234: The
type or namespace name 'Linq' does not
exist in the namespace 'System' (are
you missing an assembly reference?)
Microsoft (R) Visual C# 2005 Compiler
version 8.00.50727.3053 for Microsoft
(R) Windows (R) 2005 Framework version
2.0.50727 Copyright (C) Microsoft Corporation 2001-2005. All rights
reserved.
I know that changing to the latest version of ASP.NET / Framework will fix this - but I just can't figure out HOW to make that change in Flexbuilder. I cant even remember if i ever successfully did it before or if I just created a virtual directory in IIS7.
Where would I change the version?
It turned out I only had a very minimal web.config file set up.
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<directoryBrowse enabled="true" />
</system.webServer>
</configuration>
Once I opened the project in Visual Studio (which I hadn't done) - it upgraded the web.config to one of those really long ones and then the 3.5 framework was used. I didn't have to make any changes in the Flex environment.

Resources