Comments (16)
Played a bit with code and my samples and got it working with next change #47
Would be good to review/validate that fix.
Few notes about AcessViolationException I've got in my app:
- I was getting AcccessViolationException from time to time in .net472 app when tried to process batch of files in the same process. And wasn't getting error when tried to process one file per new process.
- Was getting AccessViolation all the time in .net5 app
from ifiltertextreader.
Tested it out and so far, so good.
from ifiltertextreader.
Nice and all credits go to @Happi-cat
from ifiltertextreader.
We are seeing a System.AccessViolationException
in IFilterTextReader Version=1.7.3
after upgrading to .net 5 - but it does not happen on .net 3.1
I haven't stepped into the library code, but we are just calling ReadToEnd
and I assume it's similar location:
Fatal error. System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at System.Runtime.InteropServices.Marshal.Release(IntPtr)
at IFilterTextReader.FilterReader.Read(Char[], Int32, Int32)
at IFilterTextReader.FilterReader.ReadLine()
at IFilterTextReader.FilterReader.ReadToEnd()
I will try version 1.6.5 of the library, to see if that fixes this.
Update: after changing version to 1.6.5, I don't get this error anymore.
from ifiltertextreader.
The only change that could explain the memory acces violation is this one I guess..
finally
{
if (valuePtr != IntPtr.Zero)
Marshal.Release(valuePtr);
}
Could you try the latest version with this removed and see if that solves it?
from ifiltertextreader.
Try version 1.7.4 and see if that fixes it. I just try to catch te exception because I have no idea what is going wrong. I do exactly what needed to be done to free the pointers and memory.
from ifiltertextreader.
I was trying to set up a small test in our regulatory compliance test project, and I have the same problem that is probably what is happening in your new version 1.7.4: AccessViolationExceptions
can't be caught and handled in the try / catch
blocks. They are always thrown as unhandled. So for now, the only workaround for me is to use a version which doesn't throw this exception, and we were used to using 1.6.4 so I'll continue using that.
from ifiltertextreader.
Ok learned something new here. Well if you have a document that can reprodure the error it would be helpfull.
from ifiltertextreader.
Attached is just newly created .doc file, which fails when I try ReadToEnd()
.
Relevant failing code:
var fromPath = @"C:\Sicos1977.doc";
var reader = new FilterReader(fromPath, ".doc");
var txt = reader.ReadToEnd();
tested on 1.7.4
and AccessViolationException
is thrown.
from ifiltertextreader.
Whatever I try I just can't reproduce the error, it just works fine on my system.
from ifiltertextreader.
Visual Studio 2019 on Windows 10 here, not sure if that would make a difference? This also is running in a .net 5 project
<TargetFramework>net5.0</TargetFramework>
from ifiltertextreader.
I tested it on Windows 10 and on Windows 2012 R2 server and on both system everything works fine.
from ifiltertextreader.
Well, if @gakera is having success on .net 3.1, I am hoping that my issue may possibly be something that I am doing wrong. So, at the risk of outing myself as an idiot, I have added a console app to a fork located here.
Change the DirectoryPath
at the start of the main method to where ever your documents are located and it will try and read them all. I only put the Sicos1977.doc file from #46 (comment) in my folder and I get the following error:
Fatal error. Internal CLR error. (0x80131506)
at System.Runtime.InteropServices.Marshal.Release(IntPtr)
at IFilterTextReader.FilterReader.Read(Char[], Int32, Int32)
at IFilterTextReader.FilterReader.ReadLine()
at IFilterTextReader.FilterReader.ReadToEnd()
at ConsoleApp1.Program.TryReadFile(System.IO.FileInfo)
at ConsoleApp1.Program.Main(System.String[])
When debugging, the exception message says Exception of type 'System.ExecutionEngineException' was thrown.
Edit: When I test it on the ConsoleApp1 with .Net 5.0, I am getting the AccessViolationException
error.
from ifiltertextreader.
I modified @JohZant's console app to reflect my use, and I have the same results.
https://github.com/gakera/IFilterTextReader
.net3.1 throws ExecutionEngineException
, .net 5 throws AccessViolationException
.
from ifiltertextreader.
Attached is just newly created .doc file, which fails when I try
ReadToEnd()
.Relevant failing code:
var fromPath = @"C:\Sicos1977.doc"; var reader = new FilterReader(fromPath, ".doc"); var txt = reader.ReadToEnd();
tested on
1.7.4
andAccessViolationException
is thrown.
I have same results. I retargeting the IFilterTextViewer.csproj to net5.0-windows , read some file get the same result.
But this file Sicos1977.doc
works well.
IFilterTextViewer.csproj for net5.0-windows :
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net5.0-windows</TargetFramework>
<UseWindowsForms>true</UseWindowsForms>
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
<EnableDefaultContentItems>false</EnableDefaultContentItems>
<EnableDefaultEmbeddedResourceItems>false</EnableDefaultEmbeddedResourceItems>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateResourceUsePreserializedResources>true</GenerateResourceUsePreserializedResources>
</PropertyGroup>
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{7E0C9F1B-0E41-4653-BE50-187566FB82EC}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>IFilterTextViewer</RootNamespace>
<AssemblyName>IFilterTextViewer</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>filter.ico</ApplicationIcon>
</PropertyGroup>
<!-- <ItemGroup>-->
<!-- <Reference Include="Microsoft.Win32.Registry, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">-->
<!-- <HintPath>..\packages\Microsoft.Win32.Registry.5.0.0\lib\net461\Microsoft.Win32.Registry.dll</HintPath>-->
<!-- </Reference>-->
<!-- <Reference Include="System" />-->
<!-- <Reference Include="System.Data">-->
<!-- <HintPath>C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.8\System.Data.dll</HintPath>-->
<!-- </Reference>-->
<!-- <Reference Include="System.Drawing" />-->
<!-- <Reference Include="System.Security.AccessControl, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">-->
<!-- <HintPath>..\packages\System.Security.AccessControl.5.0.0\lib\net461\System.Security.AccessControl.dll</HintPath>-->
<!-- </Reference>-->
<!-- <Reference Include="System.Security.Principal.Windows, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">-->
<!-- <HintPath>..\packages\System.Security.Principal.Windows.5.0.0\lib\net461\System.Security.Principal.Windows.dll</HintPath>-->
<!-- </Reference>-->
<!-- <Reference Include="System.Windows.Forms" />-->
<!-- </ItemGroup>-->
<ItemGroup>
<Compile Include="Reader.cs" />
<Compile Include="MainForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="MainForm.Designer.cs">
<DependentUpon>MainForm.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="MainForm.resx">
<DependentUpon>MainForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<None Include="app.config" />
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\IFilterTextReader\IFilterTextReader.csproj">
<Project>{86693e2d-c3cb-4e16-9684-94445934a9d3}</Project>
<Name>IFilterTextReader</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Content Include="filter.ico" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Win32.Registry" Version="6.0.0-preview.1.21102.12" />
<PackageReference Include="System.Resources.Extensions" Version="6.0.0-preview.1.21102.12" />
<PackageReference Include="System.Security.AccessControl" Version="6.0.0-preview.1.21102.12" />
<PackageReference Include="System.Security.Principal.Windows" Version="6.0.0-preview.1.21102.12" />
</ItemGroup>
</Project>
from ifiltertextreader.
I just uploaded a new package to nuget
from ifiltertextreader.
Related Issues (20)
- Cannot read text from .xls file HOT 11
- Text extraction hangs when reading .odt file HOT 4
- Index out of bounds reading a pdf document HOT 1
- Can't get the PDF filter to load the IPersistStream in FileLoader.cs HOT 4
- Question of requirements: does not contain a method named 'new' HOT 5
- TextReader not recognixing line breaks in .docx File HOT 4
- Keep file formatting HOT 1
- Open File Reader with MemoryStream HOT 3
- Document metadata properties HOT 8
- Exception if property with multiple values exists
- Weird text encoding issue with colons and section symbols HOT 1
- Registry DLL issue after upgrading HOT 1
- System.AccessViolationException HOT 19
- Outdated(?) OffFilter.dll on Windows Server 2012 HOT 2
- OffFilt.dll AccessViolationException HOT 11
- ReadToEnd() causes "Destination Array Not Long Enough" for legacy Word files HOT 1
- Missing filter return code? HOT 7
- Cannot read text from .xls HOT 6
- License question HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ifiltertextreader.