GitLab ships a wrong C# code encoding. Maybe someone might know a reason for this and a way to fix this?
I am working on a project for something like 3 months. All that time I worked from the office, so I did not have to deploy the project locally at my home computer, only at the computer on work. There on work I somehow managed to deploy a project successfully, but here at home while deploying and setting everything up I come across errors in the project.
All due to that piece of code:
public static object ParseReferred(this JObject item, JsonSerializer serializer, RetypeEnum retype)
{
if (item == null)
{
return null;
}
if (retype == RetypeEnum.)
{
return serializer.Deserialize(item.CreateReader(), typeof(TypeRegNumber));
}
return serializer.Deserialize(item.CreateReader(), typeof(TypeTaskNumber));
}
Here is how I see that piece in GitLab:
Here is the GitLab raw view:
Raw code:
public static object ParseReferred(this JObject item, JsonSerializer serializer, RetypeEnum retype)
{
if (item == null)
{
return null;
}
if (retype == RetypeEnum.�)
{
return serializer.Deserialize(item.CreateReader(), typeof(TypeRegNumber));
}
return serializer.Deserialize(item.CreateReader(), typeof(TypeTaskNumber));
}
I suspect that the only one who could have helped me with the issue was my team lead. So, I asked him what I could do about it. He suggested the following: clearing NuGet cache, restoring NuGets, cleaning the solution, and then rebuilding the solution. I followed the steps, but with no success. I feel myself very stupid, I must have missed something.
Is it true that the only way to fix the issue is to communicate with someone who has known the codebase for sometime? Or are there other possible ways to research the issue? I am really stuck, I do not know what I can try to research the issue.
When I hover over the symbol here is what I see:
'RetypeEnum' does not contain a definition for 'ä'
When I open the RetypeEnum definition (by Ctrl+click on the RetypeEnum) here is what I see:
#region Assembly foo, Version=2.0.8.0, Culture=neutral, PublicKeyToken=null
// foo.dll
#endregion
using System.CodeDom.Compiler;
namespace foo
{
[GeneratedCode("xsd", "4.6.1055.0")]
public enum RetypeEnum
{
д = 0,
з = 1
}
}
Try to check out code files line endings.
Related
I am rebuilding an old project from a long time ago, which i did not create. I've searched around to no avail and cannot find what the reference for "DMB" shown below is. Has anyone come across this before? Or shall I rewrite it?
protected void ErrorText(string error)
{
ErrorLabel.Text = error;
if (playErrorSound && error.Length != 0)
{
DMB.Web.Sound sound = new DMB.Web.Sound();
sound.SoundUrl = "ding2.wav";
ErrorLabel.Parent.Controls.Add(sound);
}
}
Just create a UserControl called Sound with a SoundUrl property. Once you can compile you can see what context it was used in.
I have a c# library which provides some functionallity to upload data onto connected (android) devices. The dll itself gets exported via UnmangedExports to be used by an delphi application.
Here is the function which gets called by the delphi application:
[DllExport]
[return: MarshalAs(UnmanagedType.LPStr)]
public static string getDevices()
{
try
{
var devices = string.Empty;
var collection = new PortableDeviceCollection();
collection.Refresh();
foreach (var device in collection)
{
device.Connect();
if (devices != string.Empty)
{
devices += ";";
}
devices += device.FriendlyName;
device.Disconnect();
}
return devices;
}
catch (Exception e)
{
SomeClass.WriteErrorToLogFile(e);
return "ERROR";
}
}
Here is the class PortableDeviceCollection:
public class PortableDeviceCollection : Collection<PortableDevice>
{
private readonly PortableDeviceApiLib.PortableDeviceManagerClass _deviceManager;
public PortableDeviceCollection()
{
this._deviceManager = new PortableDeviceApiLib.PortableDeviceManagerClass();
}
public bool Refresh()
{
this._deviceManager.RefreshDeviceList();
// Determine how many WPD devices are connected
var deviceIds = new string[1];
uint count = 1;
this._deviceManager.GetDevices(null, ref count);
if (count > 0)
{
// Retrieve the device id for each connected device
deviceIds = new string[count];
this._deviceManager.GetDevices(deviceIds, ref count);
foreach (var deviceId in deviceIds)
{
Add(new PortableDevice(deviceId));
}
return true;
}
else
return false;
}
}
I can create the dll with visual studio and use this inside of the delphi application. When the delphi application calls the getDevices() function, i get an error on the instantiation of the PortableDeviceCollection class:
The file or assembly "Interop.PortableDeviceApiLib, Version = 1.0.0.0,
Culture = neutral, PublicKeyToken = null" or a dependency of it was
not found. The assembly is created by a runtime that is more recent
than the currently loaded runtime and can not be loaded.
ProductXY.PortableDeviceCollection..ctor()
ProductXY.ProductXYMain.getDevices()
The targetframework for the c# project is set to .Net Framework 4. Using any lower version i get an error when i try to compile the project:
The primary reference "Interop.PortableDeviceApiLib" could not be
resolved because it has an indirect dependency on the .NET Framework
assembly "mscorlib, version = 4.0.0.0, Culture = neutral,
PublicKeyToken = b77a5c561934e089", which is a higher version 4.0.0.0
than version 2.0.0.0 in the current target framework.
Please note. I have neither written the c# library nor the delphi application. Both have worked together for years. Now i have to add a functionallity to the c# library. I have not added any code to the project. I just tried to compile it again and use the dll. The only thing i did was updating the RGiesecke.DLLExport.Metadata via NuGet Packetmanager. Without updating i got an error
"Microsoft.Build.Utilities.ToolLocationHelper could not find
ildasm.exe"
I am aware of this Enumerating Windows Portable Devices in C# question. But my error is thrown before the code which is treaded by the question is reached. I still tried the solution to the question, but the action (deassamble, find and replace in the dll) which is described in the answere has already been done (otherwise my code would not have compiled).
The error message doesn't make sense to me. Interop.PortableDeviceApiLib is a COM-Lib which is not available for download in different framework-versions. I think I am missing something here.
Can anyone help me?
I was finally able to solve this problem. To be honest I don't know what finally solved this. For every one who stumbles up on this, here are the things i tried to fix this problem. They are in no specific order (since i tried everything multiple times):
Updating the RGiesecke.DLLExport packet
Changing the plattform in the Konfigurations-Manager to x86
Disassamble, edit and reassable the Interop.PortableDeviceApiLib like in this question (answeres of Christophe Geers and Bruno Klein)
Delete the reference to the Interop.PortableDeviceApiLib
Delete the reference to the Interop.PortableDeviceTypesLib
Readding the reference to the Interop.PortableDeviceApiLib
Readding the reference to the Interop.PortableDeviceTypesLib
Rebuild the project
Setting the Interoptyp embeddet on both to false (I found various statements to NOT do this, but the project was set up like this when i got it and it worked (be carefull)) on both Interop-Libs.
At least this helped me.
There are a lot of questions floating around with this problem and i've worked through them ll with no joy.
I am receiving this error:
Method 'get_UserImageCDNUrl' in type 'App.Web.WebConfig' from assembly
'App.Web, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' does
not have an implementation.
Which is really strange because I am trying to run Api.Web which has no reference to App.Web, the only thing they have in common are references to other projects (Models.Domain and Models.DTO).
I have an interface:
IResourceCompiler in an assembly "Models.Domain"
I have an abstract class which implements this interface in the same assembly (Models.Domain) called WebConfigBase
In the "App.Web" and "Api.Web" projects they each have a class called WebConfig which inherit from WebConfigBase, therefore both WebConfig classes in App and Api are implementations of IResourceCompiler.
I tried to add a property
string UserImageCDNUrl {get;}
to IResourceCompiler and added the property to WebConfigBase
public string UserImageCDNUrl
{
get { return ""; }
}
so the property would be accessible to both Api and Web projects through their own WebConfig classes, and i get the exception above.
I have looked for hours to try and see why this happens with no joy.
I've cleared my Obj folders, cleaned, rebuilt, checked for any instances in GAC (there aren't any) and i'm still stuck on this.
Everything works fine until i try to add a new property to the interface (and base class)
OK, so bizarrely adding a reference to App.Web in Api.Web and removing it again has solved the issue.
I have no idea why, but it did.
I changed the version of App.Web to 1.0.0.1 and the error was still showing 1.0.0.0, which is what prompted me to do it.
I wish there was a more reasonable explanation but there isn't. Such an infuriating issue i'm just glad to be done with it.
Best of luck to anyone else who experiences this, my thought's are with you
For the records, in my case this was caused by two projects referencing different versions of the same package. At least fixing this solved the issue.
There can be many reasons for this, all the previous answers represent a case of this problem.
What I suggest doing is:
while your program is running open Resource Monitor -> CPU tab and in the search handles input box, search for the assembly that supposedly doesn't implement that method.
In the search results you'll see the path of your assembly, and most likely the path that you see isn't the one that you expect. Delete the assembly from this unexpected path so that the correct assembly gets loaded.
In many cases I become this error.
It seems like Cached assembly and I found them in UserProfile.
My solution is:
Save solution and close Visual Studio
Delete entire folder "c:\Users(user)\AppData\Local\Microsoft\VisualStudio\14.0\ProjectAssemblies\"
Start Visual Studio
Work...
Hope it helps.
I just remove the reference of current project (which is showing error) , and add again to other project in which project this was referenced build and it start working fine.
hope this help someone.
try this
public interface IResourceCompiler
{
string UserImageCDNUrl {get;}
}
public abstract class WebConfigBase : IResourceCompiler
{
public abstract string UserImageCDNUrl {get;}
}
public class WebConfig : WebConfigBase
{
public override string UserImageCDNUrl { return "whatever you want";}
}
or that way too:
public interface IResourceCompiler
{
string UserImageCDNUrl {get;}
}
public abstract class WebConfigBase : IResourceCompiler
{
public virtual string UserImageCDNUrl {get { return string.empty;}}
}
public class WebConfig : WebConfigBase
{
public override string UserImageCDNUrl { return "whatever you want";} // or return base.UserImageCDNUrl ;
}
I was seeing this problem in Visual Studio 2017.
Upgrading to visual studio 2019 solved the problem for me.
I've been using Unity 5 for a year and everything worked fine until last week when we had the idea to update our IDE to 5.3.1 version.
Now the compiler shows two errors:
The name `Dictionary' does not exist in the current context.
The name `Items' does not exist in the current context.
both localized in a simple KeyedCollection
public class CommandProcessQueueCollection : KeyedCollection<int, CommandProcessQueue>
{
public bool TryGetQueue(int id, out CommandProcessQueue queue)
{
if (Dictionary != null)
{
return Dictionary.TryGetValue(id, out queue);
}
foreach (var i in Items)
{
var k = GetKeyForItem(i);
if (Comparer.Equals(id, k))
{
queue = i;
return true;
}
}
queue = default(CommandProcessQueue);
return false;
}
protected override int GetKeyForItem(CommandProcessQueue queue)
{
return queue.Id;
}
}
After several attempts things became even more tricky as the exact same code has been compiled in 5 different machines with 5.3.1 installed.
Well, 2 out of 5 proved to compile without any error.
Furthermore, msbuild seems to compile the code without any error as well.
Probably, there are differences, among the machines, in the .NetFramework used by Mono for compilations.
Do you have any idea about this odd issue?
PS: I'm adding using System.Collections.ObjectModel and my current API compatibility option in Unity editor is set to .NET 2.0.
Ok, my team solved.
In those machines Windows Support for Editor 5.3.1f1 was not installed therefore the standard module of webplayer was running and few API of .NET were not available.
I'm trying to update the label/publisher field using Taglib-sharp, but I can't see it anywhere in its Object Hierarchy using Object Browser.
I've searched through google and the documentation and it looks like it's a field that's not catered for.
Before I look for alternatives (can any one suggest any?) that can edit those field, I thought I'd have one last crack and ask within the StackOverflow community who is familiar with TagLib-sharp that had a more informed opinion?
Thanks in Advance,
Francis
Update : I've investigated other libraries such as mpg123 & UltraID3Lib but they seem to have the same limitations.
Well, Daniel Fuchs answer didn't work for me. But, it was a beginning.
The step by step to add a field in the TagLib-sharp code is:
Download Source
Open the File TagLib/Tag.cs and insert the following code (I inserted it below PerformersSort, line 250):
public virtual string Publisher
{
get { return ""; }
set { }
}
Open the File TagLib/Id3v2/Tag.cs and insert the following code (I inserted it below PerformersSort, line 1292):
public override string Publisher
{
get { return GetTextAsString(FrameType.TPUB); }
set { SetTextFrame(FrameType.TPUB, value); }
}
Open the File TagLib/Id3v2/FrameTypes.cs and insert the following code (I inserted it below TPOS, line 71):
public static readonly ReadOnlyByteVector TPUB = "TPUB";
Now comes the "Aha" thing. Open the File TagLib/CombinedTag.cs and insert the following code (I inserted it below PerformersSort, line 318):
public override string Publisher
{
get
{
foreach (Tag tag in tags)
{
if (tag == null)
continue;
string value = tag.Publisher;
if (value != null)
return value;
}
return null;
}
set
{
foreach (Tag tag in tags)
if (tag != null)
tag.Publisher = value;
}
}
Finally, compile the code.
IMPORTANT: I had problems compiling the code, as well. You must download the SharpZipLib dll (.NET 2.0) and include this dll in the taglib project. Also, I needed to install NUnit, which I made with Nuget. At last, I commented the GDK lib and all its errors inside the test code, since in production it won't be used.
Well TagLib# is not able to to read the publisher tag. Even the newest version (2.1.0.0) as of now won't be able to do that. As an alternative you can add this functionality yourself using the source code of TagLib#, which is freely available.
To do so, open the file TagLib/Id3v2/FrameTypes.cs and add the following line somewhere:
public static readonly ReadOnlyByteVector TPUB = "TPUB"; // Publisher field
And in the file TagLib/Id3v2/Tag.cs:
public string Publisher {
get {return GetTextAsString (FrameType.TPUB);}
set {SetTextFrame (FrameType.TPUB, value);}
}
You can then access the Publisher field using something like this
TagLib.File tf = TagLib.File.Create(...); // open file
tf.Tag.Publisher = "Label XY"; // write new Publisher
tf.Save(); // save tags
Please note, that this is an ugly hack but will work for MP3 files.
I'm not used to TagLib#, but I'm using TagLib in a Qt project, where I retrieve this information inspecting TagLib::File::properties.
Take a look at the documentation, it is just a string map with every property and values.
Hope TagLib# has this method.
Update 2019-12-30:
It looks like the main taglib project has included the publisher field, so you should just use the latest version instead. I've updated to the latest TagLib from my fork and can attest that it works as expected.
Tip : If you want to change the framework version that TagLib compiles to (at time of writing it defaults to 462 and .NET STD 2.0), you need to change the Directory.Build.Props file located in the Solutions folder.
<Project>
<PropertyGroup>
<ReleaseVersion>2.2.0.0-beta</ReleaseVersion>
<RepositoryUrl>https://github.com/mono/taglib-sharp</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<TaglibSharpTargetFramework>net472;netstandard2.0</TaglibSharpTargetFramework>
<LangVersion>latest</LangVersion>
</PropertyGroup>
</Project>
I've pasted my version above which shows that I've changed it to compile to .NET 4.7.2 instead.