I'm currently trying to take over an advanced project coded in C#.
I'm definitely a novice concerning Visual Studio. The project was left few years ago and nobody holds details concerning the development. The only thing I know is that it was developed with the help of Visual Studio 2015 community edition. I cloned the source code with SourceTree and am now trying to generate an MSI so I can continue developing on a stable and usable version of the code.
After building the solution, I had to install few missing library including Clipper for some of the projects (version 6.4.0 by Angus Johnson). After that, most of the errors concerning Clipper disappeared but, for some reason, I still get unrecognized methods when using them with Clipper objects. I looked up and those methods should definitely exist in the library.
public static Polygons ProcessEvenOdd(this Polygons polygons)
{
var ret = new Polygons();
var clipper = new Clipper();
clipper.AddPaths(polygons, PolyType.ptSubject, true);
clipper.Execute(ClipType.ctUnion, ret);
return ret;
}
For example, here I get:
CS1061 'Clipper' does not contain a definition for 'AddPaths' and no extension method 'AddPaths' accepting a first argument of type 'Clipper' could be found (are you missing a using directive or an assembly reference?)
for (int i = 0; i < insetCount; i++)
{
// Increment by half the offset amount
currentOffset += offsetBy;
Polygons currentInset = part.IslandOutline.Offset(-currentOffset);
// make sure our polygon data is reasonable
currentInset = Clipper.CleanPolygons(currentInset, minimumDistanceToCreateNewPosition);
// check that we have actual paths
if (currentInset.Count > 0)
{
part.InsetToolPaths.Add(currentInset);
// Increment by the second half
currentOffset += offsetBy;
}
else
{
// we are done making insets as we have no area left
break;
}
if (i == 0)
{
// Reset offset amount to half the standard extrusion width
offsetBy = extrusionWidth_um / 2;
}
}
Here, I get:
CS0117 'Clipper' does not contain a definition for 'CleanPolygons'
Is there any reason those could stay unrecognizable for Visual Studio?
Related
When I use the code satable for the unity 2021 in the unity 2019.
The console shows that
'UnityWebRequest' does not contain a definition for 'result' and no accessible extension method 'result' accepting a first argument of type 'UnityWebRequest' could be found (are you missing a using directive or an assembly reference?)
Bugs/problem:
if (req.result == UnityWebRequest.Result.ConnectionError || req.result == UnityWebRequest.Result.ProtocolError)
I expect I can use those code on unity 2019 with other codes and works.
Simply consult the API!
result was added in version 2020.3.
Prior to that version simply follow the examples from the according version API e.g. 2019.4 API
You can e.g. simply check if there is any content in error
using (var webRequest = UnityWebRequest.Get(uri))
{
yield return webRequest.SendWebRequest();
if (!string.IsNullOrWhiteSpace(webRequest.error))
{
Debug.LogError($"Error {webRequest.responseCode} - {webRequest.error}");
yield break;
}
Debug.Log(webRequest.downloadHandler.text);
}
or if you want to further differentiate isNetworkError (includes errors like no internet connection, host not reachable, DNS resolve error etc) and isHttpError (basically same as responseCode >= 400)
If your question is about downwards compatibility but support both versions either stick to the pre-2020.3 way or use Conditional Compilation and do e.g.
#if UNITY_2020_3_OR_NEWER
if(webRequest.result == UnityWebRequest.Result.ConnectionError || webRequest.result == UnityWebRequest.Result.ProtocolError)
#else
if(!string.IsNullOrWhiteSpace(webRequest.error))
#endif
{
Debug.LogError($"Error {webRequest.responseCode} - {webRequest.error}");
yield break;
}
I'm pretty new to Unity so forgive me If I didn't give you enough information but whenever I open project in Unity I get a few errors.
First two are: Unity Error Image
#1:
***Library\PackageCach\.com.unity.postprocessing#2.0.3-preview\PostProccessing\Runtime\PostProcessManager.cs(424,66):error CS0117:'EditorSceneManager' does not contain a definition for 'IsGameObjectInScene'\***
#2: ***Library\PackageCach\.com.unity.postprocessing#2.0.3-preview\PostProccessing\Runtime\PostProcessManager.cs(425,66):error CS0117:'EditorSceneManager' does not contain a definition for 'IsGameObjectInMainScene'***
If I go into the code and delete these two lines
? UnityEditor.SceneManagement.EditorSceneManager.IsGameObjectInScene(volume.gameObject, customScene)
: UnityEditor.SceneManagement.EditorSceneManager.IsGameObjectInMainScenes(volume.gameObject);
From this
#if UNITY_2018_3_OR_NEWER && UNITY_EDITOR
// If the current camera have a custom scene then the camera is rendering that scene,
// otherwise the camera is rendering the scenes in the SceneManager.
var customScene = camera.scene;
return customScene.IsValid()
? UnityEditor.SceneManagement.EditorSceneManager.IsGameObjectInScene(volume.gameObject, customScene)
: UnityEditor.SceneManagement.EditorSceneManager.IsGameObjectInMainScenes(volume.gameObject);
#else
return true;
It gives me a Syntax error in Unity :
; expected
When I fix that error it gives me this error:
**Library\PackageCache\com.unity.postprocessing#2.0.3-preview\PostProcessing\Editor\Utils\PostProcessShaderIncludePath.cs(10,10): error CS0619: 'ShaderIncludePathAttribute' is obsolete: '[ShaderIncludePath] attribute is no longer supported. Your shader library must be under the Assets folder or in a package. To include shader headers directly from a package, use #include "Packages/<package name>/<path to your header file>"'**
After I delete this line of code:
[ShaderIncludePath]
From this:
#if UNITY_2018_1_OR_NEWER
[ShaderIncludePath]
#endif
public static string[] GetPaths()
{
var srpMarker = Directory.GetFiles(Application.dataPath, "POSTFXMARKER", SearchOption.AllDirectories).FirstOrDefault();
var paths = new string[srpMarker == null ? 1 : 2];
var index = 0;
if (srpMarker != null)
{
paths[index] = Directory.GetParent(srpMarker).ToString();
index++;
}
paths[index] = Path.GetFullPath("Packages/com.unity.postprocessing");
return paths;
After fixing all that I can use Unity normally. If this has no future effect on exporting my project I'm fine with deleting it every time. But I have zero idea what any of that code does, so If anyone can help me or knows how to solve it please let me know.
Judging by the fact that the post processing package is version 2.0.3 (preview), and the latest stable is 2.3.0 as of January 2020, I'm going to suggest that you're using grossly outdated packages.
Firstly, check to see if you Unity Editor is up-to-date by using your Unity Hub app, to "Add" new Unity versions. I would suggest if you're looking for the widely regarded, most stable version, grabbing 2019.4 LTS. Otherwise, if you're looking for that "new" thing, the 2020.2 beta is fairly stable under most conditions, but has the benefit of including the new tools and features.
Next, open up your Package Manager under the Window menu, and then check to see if all of your packages are up-to-date.
Once your Unity Editor and packages are all up-to-date, you'll more than likely find this error is resolved. I also suggest updating now, as you've said you're new to Unity, and I'm assuming you're not halfway through a major project. It's generally considered unwise to update your Unity Editor to new major versions partway through a project without a compelling reason.
hope its something simple stupid, but I am spinning my wheels.
I have a Surface Pro 4, Windows 10 and using Visual Studio 2013 Professional.
Developing WPF using C# 4.5.
In summary, all I am trying to do a simple camera capture to save an image without resorting to other 3rd party libraries I have no control over. The rest of this post are details of other research findings that I HAVE looked into and tried working out and what has failed and what such message from the compiler.
Again, simple camera, capture picture, save to disk, but all the async-await options appear to throw compiler errors.
EDIT 1 SAMPLE CODE
Here is code from the WPF form. I do not even have any control in the form as I can not even get the 'await' to compile.
using System;
using Windows.Media.Capture;
using System.Windows;
namespace CameraCapture
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
JustDoIt();
}
private MediaCapture _mediaManager;
private async void JustDoIt()
{
//initialize mediacapture with default camera
_mediaManager = new MediaCapture();
await _mediaManager.InitializeAsync();
if (_mediaManager == null)
MessageBox.Show("Failed Initialize");
await _mediaManager.StartPreviewAsync();
}
}
}
And my project also has per other links researched from below, the dlls for
System.Runtime.dll and
System.Runtime.WindowsRuntime.dll
Compile error for each of the 'await'
Error 1 'await' requires that the type 'Windows.Foundation.IAsyncAction' have a suitable GetAwaiter method. Are you missing a using directive for 'System'?
and I have "using System;" as the first line. Is there some other "await" going on when using WinRT vs default System include?
END OF EDIT
I started with https://msdn.microsoft.com/en-us/library/windows/apps/windows.media.capture.cameracaptureui.aspx
CameraCaptureUI class
I then found this link https://www.eternalcoding.com/?p=183
How to use specific WinRT API from Desktop apps
I tried going through all the steps as outlined and getting errors associated with
await ... have a suitable GetAwaiter method.
So, I looked up about asynch and await and came across
How and When to use `async` and `await`
how and when to use async and await.
So, I scrapped the first camera capture project, started a new, and did that version
that has simple thread.sleep delay to show the concept of asynch / await. That part works.
So now, I add back the reference to the project and manually edit to add the
<PropertyGroup>
<TargetPlatformVersion>8.0</TargetPlatformVersion>
</PropertyGroup>
to expose the References expose the Windows / Core per the first link and then getting access to the Windows.Media, Windows.Storage. I add in just the first little bit of code about the CameraCaptureUI and CaptureFileAsync as just a starting point such as...
private async void Camera1()
{
var cameraUi = new Windows.Media.Capture.CameraCaptureUI();
var capturedMedia = await cameraUi.CaptureFileAsync(Windows.Media.Capture.CameraCaptureUIMode.Video);
if (capturedMedia == null)
return;
MessageBox.Show("Valid Camera");
}
and get a compile error about:
'await' requires that the type
'Windows.Foundation.IAsyncOperation'
have a suitable GetAwaiter method.
Are you missing a using directive for 'System'?
Also, back to the original Windows version attempt via
private async void Camera2()
{
CameraCaptureUI dialog = new CameraCaptureUI();
Windows.Foundation.Size aspectRatio = new Windows.Foundation.Size(16, 9);
dialog.PhotoSettings.CroppedAspectRatio = aspectRatio;
StorageFile file = await dialog.CaptureFileAsync(CameraCaptureUIMode.Photo);
if (file == null)
return;
MessageBox.Show("Valid Storage File Captured");
}
I even have System.Runtime and System.RunTime.WindowsRuntime as references to the project but still fail on compile.
What am I missing. I know things change between different versions such as Windows 8.1 and Windows 10, and upgrades to features / libraries, but why await works one way, but not another.
For those scratching their heads as I did, I finally came across another post that had a missing link...
How can i import windows.media.capture in my WPF project?
The difference was the
<TargetPlatformVersion>8.1</TargetPlatformVersion>
instead of 8.0.
8.1 showed many of the individual .dll references of Foundation, Media, etc but not the single "Windows" dll.
Once changed to 8.1 and recognized the WINDOWS dll, all worked with respect to the media manager or CameraCaptureUI options.
I try to add accelerator movement to my Windows Phone Monogame application and this is what happens
Error 3
The type 'Microsoft.Xna.Framework.Vector3' is defined in an assembly that is not referenced. You must add a reference to assembly 'Microsoft.Xna.Framework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553'.
Error 2 Cannot implicitly convert type 'Microsoft.Xna.Framework.Vector3' to 'Microsoft.Xna.Framework.Vector3
Here is the line
private void UpdateUI(AccelerometerReading accelerometerReading)
{
Vector3 acceleration = accelerometerReading.Acceleration;
}
I added the Monogame.Framework.WindowsPhone project, which includes class Vector3, doesnt work.
I added the assembly Microsoft.Xna.Framework, shows the yellow triangle and a warning that
"Warning 5 The referenced component 'Microsoft.Xna.Framework' could not be found. "
The error was reported on MSDN site and no one responded. I found a smiliar problem, bo their solution doesnt work for me.
Im 12 hours into this and still nothing. I dropped the Unity, I dropped the Cocos2d, I dropped the XNA, becouse of 1231231 errors reported by Visual Studio.
Please help me Obi Wan Kenobi, you're my only hope.
I've the same issue here. As a workaround, I've moved the accelerometer logic to a Project without Monogame references and all is working properly with this solution.
For instance, you can have something like:
public class Utils
{
public static void ReadAccelerometer(Accelerometer accelerometer, out bool moveLeft, out bool moveRight)
{
AccelerometerReading accelerometerReading = accelerometer.CurrentValue;
Vector3 acceleration = accelerometerReading.Acceleration;
// establish the conditions to move left or right
}
}
Why does this code throw ShimNotSupportedException in operator?
ShimStreamReader.AllInstances.EndOfStreamGet = ((s)=>calls < 1);
[TestMethod]
public void GetAllLinesFromFile__()
{
int calls = 0;
using (ShimsContext.Create())
{
ShimStreamReader.AllInstances.EndOfStreamGet = ((s)=>calls < 1);
ShimStreamReader.AllInstances.ReadLine = (s) =>
{
calls++;
return ";;;;;;;;;;";
};
var streamFake = new ShimStreamReader();
var obj = new MyFile(streamFake, ';');
Assert.IsTrue(obj.GetAllLinesFromFile().Count() == 1);
}
}
Could it be that you are running the test from Resharper or some other testrunner?
I've written a few blogposts related to this which may be helpful:
http://blog.degree.no/2012/09/visual-studio-2012-fakes-shimnotsupportedexception-when-debugging-tests/
http://blog.degree.no/2012/09/unit-testing-visual-studio-2012-fakes-in-team-city/
I ran your code and works fine in VS 2012 RC. I did face the similar issue when I opened a solution in VS 11 Beta which was created in VS 2010. The only workaround I figured out was to create a new solution in VS 11 Beta.
One of the possible causes is missing of the fakesconfig files which should have been generated along with your xxx.fakes.dll.
I used a central project to generate Fake assemblies, and use other projects which depend on the central project to consume the generated Fake assemblies.
Let's call the Fake assembly consuming project FOO.
I did encounter the ShimNotSupportedException. After some investigation(several days!), I found that the fakesconfig files were not copied along with the Fake assemblies to the folder where FOO.dll resides. After copying fakesconfig files there, my tests passed.
Hope this helps.
Another case where this happens is when you have Typemock installed and it is enabled.
Disable on Typemock -> Suspend Mocking