Error: itgeneor003 Object metadata could not be retrieved for 'customers1' when creating table - exact-online

When trying to execute the query below with the Exact Online Adapter in the Excel 2016 for Windows on Windows 10. We get the error Object metadata could not be retrieved for 'customers'. with error code itgeneor003.
create or replace table customers#inmemorystorage
as
select act.id ctr_id
, act.code ctr_code
, act.name ctr_name
, prt.code parent_code
, prt.name parent_name
from exactonlinerest..Accounts act
left
outer
join exactonlinerest..accounts prt
on prt.id = act.parent
We got the stacktrace exception below:
Type: Invantive.Configuration.InvantiveSystemException
bij Invantive.Configuration.ValidationException..ctor(String errorCode, String errorMessage, String kindRequest, String localStackTrace, String nk, Exception innerException)
bij Invantive.Configuration.InvantiveSystemException..ctor(String validationCode, String errorMessage, String kindRequest, String stackTrace, String nk, Exception innerException)
bij Invantive.Data.ExactOnlineProvider.GetObjectMetadataForCall(EntityFieldCollection entityFields, EntityFieldCollection& correctedEntityFields)
bij Invantive.Data.ExactOnlineProvider.InsertReturnAffectedCount(EntityFieldCollection entityFields, ParameterList values, Int32& result)
bij Invantive.Data.ConnectionManager.ExecuteProviderInsertReturnAffectedCount(EntityFieldCollection entityFields, ParameterList values, String& handlingPath)
bij Invantive.Data.ConnectionManager.InsertQueryWithAffectedCount(EntityFieldCollection entityFields, ParameterList values)
bij Invantive.Sql.DdlStatementTree.OnExecute(ParameterList parameters, ExpressionParser expressionParser)
bij Invantive.Sql.QueryTree.Execute(ParameterList parameters, ExpressionParser expressionParser)
bij Invantive.Sql.QueryPlan.ForcePlan()
bij Invantive.Sql.QueryPlan.get_Fields()
bij Invantive.Data.ConnectionManager.ExecuteProviderPassthroughSqlActionTable(String actionSql, ParameterList parameters, String& handlingPath)
bij Invantive.Data.ConnectionManager.PassthroughSqlActionTable(String actionSql, ParameterList parameters)
bij Invantive.Data.ActionProceduresBase.PassthroughSqlActionTable(String actionSql, ParameterList parameters)
bij Invantive.Producer.Windows.Forms.QueryTool.ExecuteStatement(IProgressNotifier notifier, String statement, ParameterList bindVariables, Boolean showResultsInGrid, Boolean showStatistics, Boolean memorizeStatisticsInSqlHistory, Boolean allowPaging)
bij Invantive.Producer.Windows.Forms.QueryTool.FetchResultsFromSql()
bij Invantive.Producer.Windows.Forms.QueryTool.<>c__DisplayClass109_0.<FetchData>b__0()
bij System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
bij System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
bij System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
bij System.Threading.ThreadHelper.ThreadStart()
bij Invantive.Data.ExactOnlineProvider.GetObjectMetadataForCall(EntityFieldCollection entityFields, EntityFieldCollection& correctedEntityFields) in File299:regel 1791
bij Invantive.Data.ExactOnlineProvider.InsertReturnAffectedCount(EntityFieldCollection entityFields, ParameterList values, Int32& result) in File299:regel 1054
bij Invantive.Data.ConnectionManager.ExecuteProviderInsertReturnAffectedCount(EntityFieldCollection entityFields, ParameterList values, String& handlingPath) in File39:regel 3413
bij Invantive.Data.ConnectionManager.InsertQueryWithAffectedCount(EntityFieldCollection entityFields, ParameterList values) in File39:regel 1529
bij Invantive.Sql.DdlStatementTree.OnExecute(ParameterList parameters, ExpressionParser expressionParser) in File121:regel 216
bij Invantive.Sql.QueryTree.Execute(ParameterList parameters, ExpressionParser expressionParser) in File141:regel 100
bij Invantive.Sql.QueryPlan.ForcePlan() in File140:regel 77
bij Invantive.Sql.QueryPlan.get_Fields() in File140:regel 65
bij Invantive.Data.ConnectionManager.ExecuteProviderPassthroughSqlActionTable(String actionSql, ParameterList parameters, String& handlingPath) in File39:regel 4021
--- Einde van stacktracering vanaf vorige locatie waar uitzondering is opgetreden ---
bij System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
bij Invantive.Data.ConnectionManager.ExecuteProviderPassthroughSqlActionTable(String actionSql, ParameterList parameters, String& handlingPath) in File39:regel 4053
bij Invantive.Data.ConnectionManager.PassthroughSqlActionTable(String actionSql, ParameterList parameters) in File39:regel 2093
--- Einde van stacktracering vanaf vorige locatie waar uitzondering is opgetreden ---
bij System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
bij Invantive.Data.ConnectionManager.PassthroughSqlActionTable(String actionSql, ParameterList parameters) in File39:regel 2107
bij Invantive.Data.ActionProceduresBase.PassthroughSqlActionTable(String actionSql, ParameterList parameters) in File29:regel 134
bij Invantive.Producer.Windows.Forms.QueryTool.ExecuteStatement(IProgressNotifier notifier, String statement, ParameterList bindVariables, Boolean showResultsInGrid, Boolean showStatistics, Boolean memorizeStatisticsInSqlHistory, Boolean allowPaging) in File949:regel 2825
bij Invantive.Producer.Windows.Forms.QueryTool.FetchResultsFromSql() in File949:regel 2451

The error can be reproduced when the InMemoryStorage provider is not available. Although the message is confusing, it signals that an error occurred during creation of the in memory table.
Please make sure that the InMemoryStorage provider is available and licensed. Some ways to do this:
Look at the list of available objects in the Query Tool of Invantive Control, it should list the InMemoryStorage provider as shown below:
Note that the Conversion provider is probably not available on your PC; it is only for complex data conversions between platforms.
Or query the availability using:
select *
from exactonlinerest..systemproviders
The resulting list should display it:
When not available please check which product you are using. With Invantive Control it should be available always (see Help -> License -> Components), but for instance with Invantive Query Tool it is not available. Use a product that has it and ensure your license includes it too.

Related

Failure in Deserialization of File (NewtonSoft.JSON & VB.NET) [duplicate]

This question already has answers here:
How can I parse a JSON string that would cause illegal C# identifiers?
(3 answers)
Cannot deserialize the JSON array (e.g. [1,2,3]) into type ' ' because type requires JSON object (e.g. {"name":"value"}) to deserialize correctly
(6 answers)
Closed 1 year ago.
I have a small test file I'm trying to work with to deserialize the data into a model. I've already this using tokens in NewtonSoft.JSON but would rather do this properly with a model.
Example JSON
[
{
"faction": "Britain",
"id": "aa_barrage",
"image": "aa_barrage.png",
"import_id": "02",
"kredits": 1,
"rarity": "Standard",
"set": "Base",
"text": {
"de-DE": "Die gewählte Lufteinheit muss sich zurückziehen. Gibt deinem HQ +2 Verteidigung.",
"en-EN": "Target air unit must retreat. Give your HQ +2 defense.",
"es-ES": "La unidad aérea seleccionada debe retirarse. Otorga un +2 de defensa a tu cuartel general.",
"fr-FR": "L'unité aérienne visée doit battre en retraite. Confère +2 de défense à votre QG",
"it-IT": "L'unità aerea bersaglio deve Ritirarsi. Dai al tuo QG +2 difesa.",
"pl-PL": "Wybrana jednostka powietrzna musi się wycofać. Zapewnij swojemu sztabowi +2 do obrony.",
"pt-BR": "A unidade aérea na mira deve recuar. Dê +2 de defesa ao seu QG.",
"ru-RU": "Выбранный воздушный отряд должен отступить. Ваш штаб получает +2 к защите.",
"zh-Hans": "使一个空军撤退,你的总部获得 +2 防御力。",
"zh-Hant": "使一個空軍撤退,你的總部獲得 +2 防禦力。"
},
"title": {
"de-DE": "FLAK-SPERRFEUER",
"en-EN": "AA BARRAGE",
"es-ES": "BOMBARDEO AA",
"fr-FR": "BARRAGE AA",
"it-IT": "CONTRAEREA",
"pl-PL": "ZAPORA PRZECIWLOTNICZA",
"pt-BR": "BARRAGEM AA",
"ru-RU": "ЗЕНИТНЫЙ ОГОНЬ",
"zh-Hans": "防空弹幕",
"zh-Hant": "防空彈幕"
},
"type": "order"
},
{
"faction": "Britain",
"id": "active_sonar",
"image": "active_sonar.png",
"import_id": "fy",
"kredits": 0,
"rarity": "Elite",
"set": "OnlySpawnable",
"text": {
"de-DE": "Setzt alle feindlichen Einheiten fest. Karten in der gegnerischen Hand kosten 3 mehr.",
"en-EN": "Pin all enemy units. Increase cost of all cards in enemy hand by 3.",
"es-ES": "Inmoviliza todas las unidades enemigas. Las cartas en la mano del enemigo cuestan 3 más.",
"fr-FR": "Immobilise toutes les unités ennemies. Les cartes dans la main de l'ennemi coûtent 3 de plus.",
"it-IT": "Blocca tutte le unità nemiche. Aumenta di 3 il costo delle carte nella mano del nemico.",
"pl-PL": "Przyszpil wszystkie wrogie jednostki. Koszt kart w ręce przeciwnika wzrasta o 3.",
"pt-BR": "Imobilize todas as unidades inimigas. Todas as cartas na mão do inimigo custam mais 3.",
"ru-RU": "Блокирует все вражеские отряды. Карты в руке противника стоят на 3 больше.",
"zh-Hans": "压制敌方所有单位。对手所有手牌花费 +3。",
"zh-Hant": "壓制敵方所有單位。對手所有手牌花費 +3。"
},
"title": {
"de-DE": "AKTIVES SONAR",
"en-EN": "ACTIVE SONAR",
"es-ES": "SONAR ACTIVO",
"fr-FR": "SONAR ACTIF",
"it-IT": "SONAR ATTIVO",
"pl-PL": "AKTYWNY SONAR",
"pt-BR": "SONAR ATIVO",
"ru-RU": "АКТИВНЫЙ СОНАР",
"zh-Hans": "主动声呐",
"zh-Hant": "主動聲納"
},
"type": "order"
}
]
The current code I have for this is the following:
Module Program
Sub Main(args As String())
dim json As string = File.ReadAllText("C:\Temp\cards.json")
dim result As cards = JsonConvert.DeserializeObject(Of cards)(json)
End Sub
End Module
Public Class cards
public property cards as list(of card)
End Class
Public Class card
public property faction as string
public property id as string
public property image as string
public property import_id as string
public property kredits as integer
public property rarity as string
<JsonProperty("set")>
public property cardset as string
public property type as string
End Class
I can deserialize just one of these on its own, however when I try and deserialize with both it fails due to the following:
Newtonsoft.Json.JsonSerializationException: Cannot deserialize the current JSON array (e.g. [1,2,3]) into type 'json_deserialize_test.cards' because the type requires a JSON object (e.g. {"name":"value"}) to deserialize correctly.
To fix this error either change the JSON to a JSON object (e.g. {"name":"value"}) or change the deserialized type to an array or a type that implements a collection interface (e.g. ICollection, IList) like List<T> that can be deserialized from a JSON array. JsonArrayAttribute can also be added to the type to force it to deserialize from a JSON array.
I have tried changing my deserialization to:
dim result As cards = JsonConvert.DeserializeObject(Of List(Of cards))(json)
but to no available, something that was mentioned in another question, can someone point me in the right direction here please, I feel like I've been looking at it too long and need another pair of eyes.

MySql + EF 6 GroupBy cause NullReferenceException

After migration from MSSQL to the MySql I faced this issue with some queries.
Packets - .Net 4.8, EF 6.4.4, MySql.Data 8.0.22, MySql.Data.EntityFramework 8.0.22
For example, this query with GroupBy statement caused NRE:
var finalActivities = from examActivity in activitiesFilteredForReport
orderby examActivity.CreateTime descending
group examActivity by axamActivity.CreateTime into gr
select gr.FirstOrDefault();
Exception StackTrace:
System.NullReferenceException: Object reference not set to an instance of an object.
at MySql.Data.EntityFramework.CaseFragment.Accept(SqlFragmentVisitor visitor)
at MySql.Data.EntityFramework.CaseFragment.Accept(SqlFragmentVisitor visitor)
at MySql.Data.EntityFramework.BinaryFragment.Accept(SqlFragmentVisitor visitor)
at MySql.Data.EntityFramework.BinaryFragment.Accept(SqlFragmentVisitor visitor)
at MySql.Data.EntityFramework.BinaryFragment.Accept(SqlFragmentVisitor visitor)
at MySql.Data.EntityFramework.BinaryFragment.Accept(SqlFragmentVisitor visitor)
at MySql.Data.EntityFramework.BinaryFragment.Accept(SqlFragmentVisitor visitor)
at MySql.Data.EntityFramework.SelectGenerator.Visit(DbApplyExpression expression)
at MySql.Data.EntityFramework.SqlGenerator.VisitInputExpression(DbExpression e, String name, TypeUsage type)
at MySql.Data.EntityFramework.SelectGenerator.HandleJoinExpression(DbExpressionBinding left, DbExpressionBinding right, DbExpressionKind joinType, DbExpression joinCondition)
at MySql.Data.EntityFramework.SelectGenerator.Visit(DbJoinExpression expression)
at MySql.Data.EntityFramework.SqlGenerator.VisitInputExpression(DbExpression e, String name, TypeUsage type)
at MySql.Data.EntityFramework.SelectGenerator.VisitInputExpressionEnsureSelect(DbExpression e, String name, TypeUsage type)
at MySql.Data.EntityFramework.SelectGenerator.Visit(DbFilterExpression expression)
at MySql.Data.EntityFramework.SqlGenerator.VisitInputExpression(DbExpression e, String name, TypeUsage type)
at MySql.Data.EntityFramework.SelectGenerator.VisitInputExpressionEnsureSelect(DbExpression e, String name, TypeUsage type)
at MySql.Data.EntityFramework.SelectGenerator.Visit(DbProjectExpression expression)
at MySql.Data.EntityFramework.SelectGenerator.GenerateSQL(DbCommandTree tree)
at MySql.Data.MySqlClient.MySqlProviderServices.CreateDbCommandDefinition(DbProviderManifest providerManifest, DbCommandTree commandTree)
at System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition..ctor(DbProviderFactory storeProviderFactory, DbCommandTree commandTree, DbInterceptionContext interceptionContext, IDbDependencyResolver resolver, BridgeDataReaderFactory bridgeDataReaderFactory, ColumnMapFactory columnMapFactory)
at System.Data.Entity.Core.EntityClient.Internal.EntityProviderServices.CreateDbCommandDefinition(DbProviderManifest providerManifest, DbCommandTree commandTree, DbInterceptionContext interceptionContext)
at System.Data.Entity.Core.Objects.Internal.ObjectQueryExecutionPlanFactory.CreateCommandDefinition(ObjectContext context, DbQueryCommandTree tree)
at System.Data.Entity.Core.Objects.Internal.ObjectQueryExecutionPlanFactory.Prepare(ObjectContext context, DbQueryCommandTree tree, Type elementType, MergeOption mergeOption, Boolean streaming, Span span, IEnumerable`1 compiledQueryParameters, AliasGenerator aliasGenerator)
at System.Data.Entity.Core.Objects.ELinq.ELinqQueryState.GetExecutionPlan(Nullable`1 forMergeOption)
at System.Data.Entity.Core.Objects.ObjectQuery`1.<>c__DisplayClass41_0.<GetResults>b__1()
at System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransaction[T](Func`1 func, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction, Boolean releaseConnectionOnSuccess)
at System.Data.Entity.Core.Objects.ObjectQuery`1.<>c__DisplayClass41_0.<GetResults>b__0()
at System.Data.Entity.Core.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption)
at System.Data.Entity.Core.Objects.ObjectQuery`1.<System.Collections.Generic.IEnumerable<T>.GetEnumerator>b__31_0()
at System.Data.Entity.Internal.LazyEnumerator`1.MoveNext()
at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
at System.Linq.Lookup`2.Create[TSource](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer)
at System.Linq.GroupedEnumerable`3.GetEnumerator()
at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
But if I write code like this:
var finalActivities = from examActivity in activitiesFilteredForReport
orderby examActivity.CreateTime descending
group examActivity by axamActivity.CreateTime into gr
select gr.FirstOrDefault().Id;
It gives me Ids without any exception.
In this case, I apply some workaround to make code work:
var ids = activitiesFilteredForReport.GroupBy(activity => activity.OrderExamId)
.Select(g => g.FirstOrDefault().Id);
var finalActivities = from examActivity in activitiesFilteredForReport
join id in ids on examActivity.Id equals id
orderby examActivity.CreateTime descending
select examActivity;
But I not sure is it a good solution. Can anyone help me to sort this issue? What I do wrong?

Golang YAML with nested properties to JSON

I'm trying to parse some YAML from a file and convert each item to a flat JSON object.
I'm having some issues with datasets where there are multiple / nested objects.
I'm failing to unmarshal multiple items per file.
I'm unsure how to get nested properties such has item -> description -> en
When I run the following code I get the error.
cannot unmarshal !!map into []item.Item
I think I've got to look into sub-types within my structure, but I can't seem to get anything to work.
Any help would be appreciated.
Code:
import (
"gopkg.in/yaml.v2"
"io/ioutil"
)
func parseItemYaml() {
filePath := "./typeIDs.yaml"
yamlFile, err := ioutil.ReadFile(filePath)
if err != nil {
log.Printf("yamlFile.Get err #%v ", err)
}
itemData := map[int][]Item{}
err = yaml.Unmarshal(yamlFile, &itemData)
if err != nil {
panic(err)
}
// Then convert to JSON
// Eventual persistance
}
Item Structure:
type Item struct {
ID int
Name string `yaml:"name"`
Description string `yaml:"description"`
GroupID int `yaml:"groupID"`
IconID int `yaml:"iconID"`
GraphicID int `yaml:"graphicID"`
MarketGroupID int `yaml:"marketGroupID"`
Mass float64 `yaml:"mass"`
Published bool `yaml:"published"`
Volume float64 `yaml:"volume"`
}
Desired JSON format:
{
"ID":1563,
"Description":"Radiates an omnidirectional pulse from the ship that causes EM damage to surrounding vessels.",
"GroupID":72,
"IconID":112,
"GraphicID":72,
"MarketGroupID":382,
"Mass":10.0,
"Published":true,
"Volume":12.5
},
{...},
{...}
Data Subset:
1563:
description:
de: Ein ungerichteter Rundum-Impuls der vom Schiff ausgestrahlt wird und bei
umliegenden Schiffen EM-Schaden verursacht.
en: Radiates an omnidirectional pulse from the ship that causes EM damage
to surrounding vessels.
fr: Émet une impulsion omnidirectionelle qui part du vaisseau et provoque
des dégâts électromagnétiques à tous les vaisseaux situés à proximité.
ja: 全方位にパルスを放射し、周囲の艦にEMダメージを与える。
ru: Испускает сильный всенаправленный импульс, наносящий электромагнитный
ущерб всем объектам, окружающим корабль.
zh: 从舰船上发射一个全向脉冲,对周围船只造成电磁伤害。
graphicID: 2032
groupID: 72
iconID: 112
marketGroupID: 382
mass: 10.0
name:
de: Small EMP Smartbomb I
en: Small EMP Smartbomb I
fr: Petite bombe de proximité à IEM I
ja: 小型EMPスマートボムI
ru: Small EMP Smartbomb I
zh: 小型EMP立体炸弹 I
portionSize: 1
published: true
radius: 1000.0
volume: 12.5
1564:
basePrice: 650000.0
groupID: 152
iconID: 112
marketGroupID: 341
name:
de: Small EMP Smartbomb I Blueprint
en: Small EMP Smartbomb I Blueprint
fr: Plan de construction Petite bombe de proximité à IEM I
ja: 小型EMPスマートボムIブループリント
ru: Small EMP Smartbomb I Blueprint
zh: 小型EMP立体炸弹蓝图 I
portionSize: 1
published: true
volume: 0.01
1565:
description:
de: Ein ungerichteter Rundum-Impuls der vom Schiff ausgestrahlt wird und bei
umliegenden Schiffen EM-Schaden verursacht.
en: Radiates an omnidirectional pulse from the ship that causes EM damage
to surrounding vessels.
fr: Émet une impulsion omnidirectionelle qui part du vaisseau et provoque
des dégâts électromagnétiques à tous les vaisseaux situés à proximité.
ja: 全方位にパルスを放射し、周囲の艦にEMダメージを与える。
ru: Испускает сильный всенаправленный импульс, наносящий электромагнитный
ущерб всем объектам, окружающим корабль.
zh: 从舰船上发射一个全向脉冲,对周围船只造成电磁伤害。
graphicID: 2032
groupID: 72
iconID: 112
marketGroupID: 382
mass: 40.0
name:
de: Small EMP Smartbomb II
en: Small EMP Smartbomb II
fr: Petite bombe de proximité à IEM II
ja: 小型EMPスマートボムII
ru: Small EMP Smartbomb II
zh: 小型EMP立体炸弹 II
portionSize: 1
published: true
radius: 1000.0
volume: 5.0
Make structs e.g. like this:
type Language struct {
De string `yaml:de`
En string `yaml:en`
Fr string `yaml:fr`
Ja string `yaml:ja`
Ru string `yaml:ru`
Zh string `yaml:zh`
}
type Item struct {
Description Language `yaml:description`
GroupID int `yaml:"groupID"`
IconID int `yaml:"iconID"`
GraphicID int `yaml:"graphicID"`
MarketGroupID int `yaml:"marketGroupID"`
Mass float64 `yaml:"mass"`
Name Language `yaml:name`
Published bool `yaml:"published"`
Volume float64 `yaml:"volume"`
}
Also, as far as I see, it should be map[int]Item{} and not map[int][]Item{}.

Error does not get caught

I wrote a script that upload a xml file, look at the following code snippet:
open System.Xml
open System.IO
open System
type XmlErrorLoad =
| Success of XmlDocument
| FileNotFound of FileNotFoundException
| OtherException of Exception
let doc (filename:string) =
try
let file = XmlDocument()
file.Load(filename)
Success file
with
| :? FileNotFoundException as ex -> FileNotFound ex
| :? Exception as ex -> OtherException ex
let fileNotExists = doc("C:\Temp\ip2.xml")
match fileNotExists with
| Success s -> ()
| FileNotFound ex -> printfn "File not found: %s" ex.Message
| OtherException ex -> printfn "Exception: %s" ex.Message
In this case, ip2.xml file does not exist and it should throw an error FileNotFound and print on the screen.
"File not found: %s" ex.Message
But I've got the message
val fileNotExists : XmlErrorLoad =
FileNotFound
System.IO.FileNotFoundException: Could not find file 'C:\Temp\ip2.xml'.
File name: 'C:\Temp\ip2.xml'
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize)
at System.Xml.XmlDownloadManager.GetStream(Uri uri, ICredentials credentials, IWebProxy proxy, RequestCachePolicy cachePolicy)
at System.Xml.XmlUrlResolver.GetEntity(Uri absoluteUri, String role, Type ofObjectToReturn)
at System.Xml.XmlTextReaderImpl.OpenUrlDelegate(Object xmlResolver)
at System.Threading.CompressedStack.runTryCode(Object userData)
at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
at System.Threading.CompressedStack.Run(CompressedStack compressedStack, ContextCallback callback, Object state)
at System.Xml.XmlTextReaderImpl.OpenUrl()
at System.Xml.XmlTextReaderImpl.Read()
at System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace)
at System.Xml.XmlDocument.Load(XmlReader reader)
at System.Xml.XmlDocument.Load(String filename)
at FSI_0004.doc(String filename) in D:\f#\samples\ip.fsx:line 20
I've tried your code as input on F# Interactive and got the desired message
File not found: Could not find file 'C:\Temp\ip2.xml'.
Besides the output F# Interactive lists all the values defined in the code, so I also got following printed:
type XmlErrorLoad =
| Success of XmlDocument
| FileNotFound of FileNotFoundException
| OtherException of Exception
val doc : filename:string -> XmlErrorLoad
val fileNotExists : XmlErrorLoad =
FileNotFound
System.IO.FileNotFoundException: Could not find file 'C:\Temp\ip2.xml'.
File name: 'C:\Temp\ip2.xml'
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize)
at System.Xml.XmlDownloadManager.GetStream(Uri uri, ICredentials credentials, IWebProxy proxy, RequestCachePolicy cachePolicy)
at System.Xml.XmlUrlResolver.GetEntity(Uri absoluteUri, String role, Type ofObjectToReturn)
at System.Xml.XmlTextReaderImpl.OpenUrlDelegate(Object xmlResolver)
at System.Threading.CompressedStack.runTryCode(Object userData)
at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
at System.Threading.CompressedStack.Run(CompressedStack compressedStack, ContextCallback callback, Object state)
at System.Xml.XmlTextReaderImpl.OpenUrl()
at System.Xml.XmlTextReaderImpl.Read()
at System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace)
at System.Xml.XmlDocument.Load(XmlReader reader)
at System.Xml.XmlDocument.Load(String filename)
at FSI_0003.doc(String filename)
val it : unit = ()
You get this output only in F# Interactive as part of REPL feedback. In a normal program this output wouldn't be produced.

How to convert a string that contains HTML encoding characters to NSData?

I need to convert this string
"{
"name":"Tsubasa En La Liga",
"description":"T\u1ebfp sau b\u1ed9 tsubasa El classico\u2026anh \u0111\u00e3 tr\u1edf l\u1ea1i, g\u1eb7p l\u1ea1i nh\u1eefng b\u1ea1n b\u00e8 v\u00e0 \u0111\u1ed1i th\u1ee7 c\u0169 v\u00e0 c\u1ed1 g\u1eafng \u0111\u01b0a \u0111\u1ed9i tuy\u1ec3n nh\u1eadt \u0111o\u1ea1t chi\u1ebfc c\u00fap v\u00f4 \u0111\u1ecbch"
}"
to a NSData object.
I used
NSData* data = [NSData dataWithBytes:[string cStringUsingEncoding:NSASCIIStringEncoding] length:[string lengthOfBytesUsingEncoding:NSASCIIStringEncoding]];
or
NSData* data =[data dataUsingEncoding:NSASCIIStringEncoding];
And then save data to a Core Data entity.
But when I read data from the entities the result is utf8 encoded.
"{
"name":"Tsubasa En La Liga",
"description":"Tếp sau bộ tsubasa El classico…anh đã trở lại, gặp lại những bạn bè và đối thủ cũ và cố gắng đưa đội tuyển nhật đoạt chiếc cúp vô địch"
}"
I don't want the string encoded to utf8.
I want the original string should be save to Core Data entity.
Thank you.
you can fix that by escaping your backslashes. use double back-slash \\.